javac FootballGame.java java FootballGame

 avatar
unknown
java
2 years ago
805 B
4
Indexable
import java.util.Random;

public class FootballGame {

    public static void main(String[] args) {
        // Create two teams of players
        int[] team1 = new int[11];
        int[] team2 = new int[11];
        for (int i = 0; i < 11; i++) {
            team1[i] = new Random().nextInt(100);
            team2[i] = new Random().nextInt(100);
        }

        // Play the game
        int score1 = 0;
        int score2 = 0;
        for (int i = 0; i < 10; i++) {
            if (new Random().nextInt(2) == 0) {
                score1++;
            } else {
                score2++;
            }
        }

        // Display the results
        System.out.println("The final score is:");
        System.out.println("Team 1: " + score1);
        System.out.println("Team 2: " + score2);
    }
}
Editor is loading...