Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class RunningTheRace
- {
- public static void main(String[ ] args)
- {
- Scanner keyboard = new Scanner(System.in);
- String runner1, runner2, runner3;
- int score1, score2, score3;
- System.out.print("What is the name of the first runner? ");
- runner1 = keyboard.nextLine();
- System.out.print("What is this runner's score in minutes? ");
- score1 = keyboard.nextInt();
- keyboard.nextLine();
- System.out.print("What is the name of the second runner? ");
- runner2 = keyboard.nextLine();
- System.out.print("What is this runner's score in minutes? ");
- score2 = keyboard.nextInt();
- keyboard.nextLine();
- System.out.print("What is the name of the third runner? ");
- runner3 = keyboard.nextLine();
- System.out.print("What is this runner's score in minutes? ");
- score3 = keyboard.nextInt();
- if (score1 < score2 && score1 < score3)
- {
- if (score2 < score3)
- {
- System.out.println("The first place runner is " + runner1 + "\nThe second place runner is "
- + runner2 + "\nThe third place runner is " + runner3 + ". ");
- }
- else
- {
- System.out.println("The first place runner is " + runner1 + "\nThe second place runner is "
- + runner3 + "\nThe third place runner is " + runner2 + ". ");
- }
- }
- else if (score2 < score1 && score2 < score3)
- {
- if (score1 < score3)
- {
- System.out.println("The first place runner is " + runner2 + "\nThe second place runner is "
- + runner1 + "\nThe third place runner is " + runner3 + ". ");
- }
- else
- {
- System.out.println("The first place runner is " + runner2 + "\nThe second place runner is "
- + runner3 + "\nThe third place runner is " + runner1 + ". ");
- }
- }
- else if (score3 < score1 && score3 < score2)
- {
- if (score1 < score2)
- {
- System.out.println("The first place runner is " + runner3 + "\n The second place runner is "
- + runner1 + "\n The third place runner is " + runner2 + ".");
- }
- else
- {
- System.out.println("The first place runner is " + runner3 + "\n The second place runner is "
- + runner2 + "\n The third place runner is " + runner1 + ".");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement