/* * Peter Willis * glassfault@yahoo.com * March 20, 2003 */ package Skater; import IO.Keyboard; import IO.Skater; import java.text.DecimalFormat; /** * * @author willisp1 */ public class SkaterProgram { /** Creates a new instance of SkaterProgram */ public SkaterProgram() { } /** * @param args the command line arguments */ public static void main(String[] args) { // ask user how many judges there are System.out.println("How many judges working?"); int judge = Keyboard.readInt(); // validate number of judges while ((judge < 6) || (judge > 10)) { System.out.println("I'm sorry, please enter a number of judges " + "between 6 and 10."); judge = Keyboard.readInt(); } // end while Skater.setNumJudges(judge); // enter skater's name System.out.println("What is the skater's name?"); String name = Keyboard.readString(); // find skater's country System.out.println("What is the skater's country?"); String country = Keyboard.readString(); // create skater Skater skaterNew = new Skater(name, country); int judgeCount = 1; double artTotal = 0.00; // find art scores from all judges while (judgeCount <= judge) { System.out.println("Artistry Score From Judge #" + judgeCount); double artScore = Keyboard.readDouble(); // validate score input while ((artScore < 0.1) || (artScore > 6.0)) { System.out.println("I'm sorry, please enter a value between " + "0.1 and 6.0:"); artScore = Keyboard.readDouble(); } // end while skaterNew.setNthArtScore(judgeCount - 1, artScore); judgeCount++; } // get total art score artTotal = skaterNew.getArtRating(); // introduce decimal format DecimalFormat singleDecimal = new DecimalFormat("0.#"); // print artistry score System.out.println("Artistry score for " + name + " " + singleDecimal.format(artTotal)); judgeCount = 1; double techTotal = 0.00; // print blank line System.out.println(" "); // find technical score from all judges while (judgeCount <= judge) { System.out.println("Technical Score From Judge #" + judgeCount); double techScore = Keyboard.readDouble(); // validate score input while ((techScore < 0.1) || (techScore > 6.0)) { System.out.println("I'm sorry, please enter a value between " + "0.1 and 6.0:"); techScore = Keyboard.readDouble(); } // end while skaterNew.setNthTechScore(judgeCount - 1, techScore); judgeCount++; } // end while // get total technical score techTotal = skaterNew.getTechRating(); System.out.println("Technical score for " + name + " " + singleDecimal.format(techTotal)); // get total score double totalScore = skaterNew.getTotalRating(); // print blank line System.out.println(" "); System.out.println("Total score for " + name + " " + singleDecimal.format(totalScore)); return; } }