Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* David Kincaid
- * CSU score calculator, exercise 7
- * 2/21/2012
- *
- */
- import java.util.Scanner;
- public class CSU_scores {
- public static void main(String[] args) {
- //sets keyboard as input method for user
- Scanner KBin = new Scanner(System.in);
- // variables
- double x;
- double y;
- double wins = 0;
- double losses = 0;
- double ties = 0;
- double games = 0;
- //this is loop for gathering the scores and calculating the wins/losses/ties
- while(games<=9)
- {
- //this counts the number of loops
- games = games + 1;
- //This prompts the user to provide the scores
- System.out.println("What were the two scores?");
- System.out.println("CSU:");
- x = KBin.nextDouble();
- System.out.println("Opponent:");
- y = KBin.nextDouble();
- //This calculates if CSU won, lost, or tied, and adds one to the appropriate total
- if(x > y)
- wins = (wins + 1);
- else if(y > x)
- losses = (losses + 1);
- else
- ties = (ties + 1);
- }//End Loop
- //If CSU won all ten games, this congratulates the user
- if(wins>=10)
- System.out.println("Congratulations, CSU had a perfect season!");
- //If CSU did not have a perfect season, this prints the team's record
- else
- System.out.println(wins);
- System.out.println(losses);
- System.out.println(ties);
- }//End Method
- }//End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement