Advertisement
Kendred

Skater Scores

Apr 30th, 2019
575
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2. /*
  3. * Kendred Thompson
  4. * 4th Period
  5. * CS 2
  6. * Skater Scores
  7. */
  8.  
  9. public class Program {
  10.  
  11. public static void main(String[] args) {
  12.  
  13. double [] [] scores = { {5.6, 3.5, 5.9, 5.4, 5.1},
  14. {4.4, 5.4, 5.4, 5.8, 5.9},
  15. {4.5, 2.4, 4.3, 5.2, 4.5},
  16. {4.4, 5.2, 5.8, 4.9, 5.6},
  17. {5.3, 4.2, 5.5, 4.9, 4.9},
  18. {5.9, 5.6, 0.7, 4.4, 6.0},
  19. {5.1, 5.8, 3.2, 4.9, 2.8}};
  20.  
  21. //Helps round scores to 1 decimal place
  22. DecimalFormat df = new DecimalFormat("#.0");
  23.  
  24. for(int skater = 0; skater < scores.length; skater++) {
  25. System.out.println("Scores for Skater #" + (skater + 1) + ":");
  26.  
  27.  
  28. double sum = 0; //Variables of the code
  29. double max = scores[skater][0];
  30. double min = scores[skater][0];
  31.  
  32. for(int judge = 0; judge < scores[skater].length; judge++) {
  33. sum = sum + scores[skater][judge];
  34.  
  35. System.out.print(scores[skater][judge] + "\t");
  36.  
  37. if(scores[skater] [judge] > max) { //Finds the Maximum
  38.  
  39. max = scores[skater][judge];
  40.  
  41. }
  42. if(scores[skater] [judge] < min) { //Finds the Minimum
  43.  
  44. min = scores[skater][judge];
  45. }
  46. }
  47.  
  48. double avg = (sum - min - max) / (scores[skater].length-2);
  49. System.out.println();
  50. System.out.println("Average: " + df.format(avg));
  51. System.out.println();
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement