Advertisement
Nikki12345671

SkaterScores

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