Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Arrays;
  3.  
  4. public class DivingScore
  5. {
  6. public static void main(String []args)
  7. {
  8. Scanner kb = new Scanner(System.in);
  9. String[] judge = new String[7];
  10. String[] diver = new String[4];
  11. double[] finalScore = new double[4];
  12. double[] diveDifficulty = new double[7];
  13. double[][] diverScore = new double[4][7];
  14. fillArray(judge, diver, diveDifficulty, diverScore,finalScore);
  15. }
  16.  
  17. public static void fillArray(String[] judge, String[] diver, double[] diveDifficulty, double[][] diverScore, double[] finalScore)
  18. {
  19. double diveDiff = 0;
  20. Scanner kb = new Scanner(System.in);
  21. for(int i = 0; i < 7; i++)
  22. {
  23. System.out.println("Input the judges name");
  24. judge[i] = kb.nextLine();
  25. }
  26.  
  27. for(int j = 0; j < 4; j++)
  28. {
  29. System.out.println("Input the divers name");
  30. diver[j] = kb.nextLine();
  31. }
  32.  
  33. for(int k = 0; k < 7; k++)
  34. {
  35. System.out.println("Input the dive difficulty");
  36. diveDifficulty[k] = kb.nextDouble();
  37. }
  38.  
  39. for(int l = 0; l<4; l++)
  40. {
  41. for(int m = 0; m<7; m++)
  42. {
  43. System.out.println("Judge " + judge[m] + " enter the scores for " + diver[l]);
  44. diverScore[l][m] = kb.nextInt();
  45. }
  46. }
  47. findSmallest(diverScore);
  48. findLargest(diverScore);
  49. System.out.println();
  50. System.out.println("Judges");
  51. System.out.println(Arrays.toString(judge));
  52. System.out.println("Divers");
  53. System.out.println(Arrays.toString(diver));
  54. System.out.println("Dive Difficulty");
  55. System.out.println(Arrays.toString(diveDifficulty));
  56. System.out.println("Diver's Scores");
  57. for(int x = 0; x < 4; x++)
  58. {
  59. System.out.println(Arrays.toString(diverScore[x]));
  60. }
  61. calcScore(diverScore, diveDifficulty, finalScore,diver);
  62. awardMedal(finalScore, diver);
  63. }
  64. public static void findSmallest(double[][] diverScore)
  65. {
  66. int smallOne = 0;
  67. int smallTwo = 0;
  68. for(int i = 0; i<4; i++)
  69. {
  70. for(int j = 0; j<7; j++)
  71. {
  72. if(diverScore[i][j] < diverScore[i][j-1])
  73. {
  74. smallOne = i;
  75. smallTwo = j;
  76. }
  77. }
  78. diverScore[smallOne][smallTwo] = 0;
  79. }
  80. }
  81. public static void findLargest(double[][] diverScore)
  82. {
  83. int largeOne = 0;
  84. int largeTwo = 0;
  85. for(int i = 0; i<4; i++)
  86. {
  87. for(int j = 0; j<7; j++)
  88. {
  89. if(diverScore[i][j] > diverScore[i][j-1])
  90. {
  91. largeOne = i;
  92. largeTwo = j;
  93. }
  94. }
  95. diverScore[largeOne][largeTwo] = 0;
  96. }
  97. }
  98. public static void calcScore(double[][] diverScore, double[] diveDifficulty, double[] finalScore, String[] diver)
  99. {
  100. double temp = 0;
  101. double temp2 = 0;
  102. for(int i = 0; i<4; i++)
  103. {
  104. for(int j = 0; j<7; j++)
  105. {
  106. temp = temp + (diverScore[i][j] * diveDifficulty[j]);
  107. if(temp > diverScore[i-1][j-1] * diveDifficulty[j-1])
  108. {
  109. diver[i] = diver[i] + " " + temp;
  110. }
  111. }
  112. }
  113. }
  114. public static void awardMedal(double[] finalScore, String[] diver)
  115. {
  116. System.out.println(Arrays.toString(diver));
  117. }
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement