import java.util.Scanner; /** * Performs a large number of volleyball game simulations and displays statistics. * @author Dave Reed * @version 8/25/08 */ public class VolleyballStats { private final static int WINNING_POINTS = 15; private final static int NUM_GAMES = 10000; public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("What is the ranking for team 1? "); int ranking1 = input.nextInt(); System.out.print("What is the ranking for team 2? "); int ranking2 = input.nextInt(); VolleyballSimulator sim = new VolleyballSimulator(ranking1, ranking2); int team1Wins = 0; for (int game = 0; game < NUM_GAMES; game++) { if (sim.playGame(WINNING_POINTS).equals("team 1")) { team1Wins++; } } System.out.println("Out of " + NUM_GAMES + " games to " + WINNING_POINTS + ", team 1 (" + ranking1 + "-" + ranking2 + ") won: " + 100.0*team1Wins/NUM_GAMES + "%"); } }