Advertisement
DaelonSuzuka

java CSU scores

Feb 21st, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1.  
  2. /* David Kincaid
  3. * CSU score calculator, exercise 7
  4. * 2/21/2012
  5. *
  6. */
  7.  
  8.  
  9.  
  10. import java.util.Scanner;
  11. public class CSU_scores {
  12.  
  13.  
  14. public static void main(String[] args) {
  15.  
  16. //sets keyboard as input method for user
  17. Scanner KBin = new Scanner(System.in);
  18.  
  19. // variables
  20. double x;
  21. double y;
  22. double wins = 0;
  23. double losses = 0;
  24. double ties = 0;
  25. double games = 0;
  26.  
  27.  
  28. //this is loop for gathering the scores and calculating the wins/losses/ties
  29. while(games<=9)
  30. {
  31.  
  32. //this counts the number of loops
  33. games = games + 1;
  34.  
  35. //This prompts the user to provide the scores
  36. System.out.println("What were the two scores?");
  37. System.out.println("CSU:");
  38. x = KBin.nextDouble();
  39. System.out.println("Opponent:");
  40. y = KBin.nextDouble();
  41.  
  42.  
  43. //This calculates if CSU won, lost, or tied, and adds one to the appropriate total
  44. if(x > y)
  45. wins = (wins + 1);
  46. else if(y > x)
  47. losses = (losses + 1);
  48. else
  49. ties = (ties + 1);
  50.  
  51. }//End Loop
  52.  
  53.  
  54. //If CSU won all ten games, this congratulates the user
  55. if(wins>=10)
  56. System.out.println("Congratulations, CSU had a perfect season!");
  57.  
  58. //If CSU did not have a perfect season, this prints the team's record
  59. else
  60. System.out.println(wins);
  61. System.out.println(losses);
  62. System.out.println(ties);
  63.  
  64.  
  65.  
  66.  
  67.  
  68. }//End Method
  69.  
  70. }//End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement