Advertisement
Guest User

Running

a guest
Oct 12th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class RunningTheRace
  4. {
  5. public static void main(String[ ] args)
  6. {
  7. Scanner keyboard = new Scanner(System.in);
  8.  
  9. String runner1, runner2, runner3;
  10. int score1, score2, score3;
  11.  
  12. System.out.print("What is the name of the first runner? ");
  13. runner1 = keyboard.nextLine();
  14.  
  15. System.out.print("What is this runner's score in minutes? ");
  16. score1 = keyboard.nextInt();
  17.  
  18. keyboard.nextLine();
  19.  
  20. System.out.print("What is the name of the second runner? ");
  21. runner2 = keyboard.nextLine();
  22.  
  23. System.out.print("What is this runner's score in minutes? ");
  24. score2 = keyboard.nextInt();
  25.  
  26. keyboard.nextLine();
  27.  
  28. System.out.print("What is the name of the third runner? ");
  29. runner3 = keyboard.nextLine();
  30.  
  31. System.out.print("What is this runner's score in minutes? ");
  32. score3 = keyboard.nextInt();
  33.  
  34. if (score1 < score2 && score1 < score3)
  35. {
  36. if (score2 < score3)
  37. {
  38. System.out.println("The first place runner is " + runner1 + "\nThe second place runner is "
  39. + runner2 + "\nThe third place runner is " + runner3 + ". ");
  40. }
  41. else
  42. {
  43. System.out.println("The first place runner is " + runner1 + "\nThe second place runner is "
  44. + runner3 + "\nThe third place runner is " + runner2 + ". ");
  45. }
  46. }
  47.  
  48. else if (score2 < score1 && score2 < score3)
  49. {
  50. if (score1 < score3)
  51. {
  52. System.out.println("The first place runner is " + runner2 + "\nThe second place runner is "
  53. + runner1 + "\nThe third place runner is " + runner3 + ". ");
  54. }
  55. else
  56. {
  57. System.out.println("The first place runner is " + runner2 + "\nThe second place runner is "
  58. + runner3 + "\nThe third place runner is " + runner1 + ". ");
  59. }
  60. }
  61.  
  62. else if (score3 < score1 && score3 < score2)
  63. {
  64. if (score1 < score2)
  65. {
  66. System.out.println("The first place runner is " + runner3 + "\n The second place runner is "
  67. + runner1 + "\n The third place runner is " + runner2 + ".");
  68. }
  69. else
  70. {
  71. System.out.println("The first place runner is " + runner3 + "\n The second place runner is "
  72. + runner2 + "\n The third place runner is " + runner1 + ".");
  73. }
  74. }
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement