//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //NHL Shootout //Description: Simulates an ice hockey shootout based on goaltender save // percentages. //CS 284 //Programmed by Jonathan Voris //for 1/24/06 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //for keyboard input import java.util.Scanner; class shootout { //create a new scanner for reading keyboard input static Scanner sc = new Scanner(System.in); //create static variables for goalie save percentages. stats found at: //http://www.nhl.com/nhlstats/stats?service=direct&context=Home/reportBuilder.shootoutGoaliesLink static double BrodeurSavePercentage = .87; static double LundqvistSavePercentage = .821; //The score function takes a goalie's save percentage and the //shooting team name. It then outputs a score or miss to the //console and returns true for a score and false for a miss. public static boolean score(double savePercentage, String team) { //generate a random number and compare it to the defending //goalie's save percentage if (Math.random() >= savePercentage) { System.out.println(team + " score!"); return true; } else { System.out.println("No luck for the " + team); return false; } } public static void main(String[] args) { //get number of rounds from the user System.out.print("How many rounds did the shoot out last?"); int round = sc.nextInt(); //determine who won the shoot out whoWon(round, 0, 0); } }