Advertisement
Guest User

SkaterScores

a guest
Apr 25th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1.  
  2. //Anthony Conner
  3. //Skater Scores
  4. //4-25-19
  5.  
  6. import java.text.DecimalFormat;
  7.  
  8. public class Program {
  9.  
  10. public static void main(String[] args) {
  11.  
  12. //Scores
  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. //Doubles to get the scores
  25. for(int skater = 0; skater < scores.length; skater++) {
  26. System.out.println("Scores for Skater #" + (skater + 1) + ":");
  27. double sum = 0;
  28. double min = 6;
  29. double max = 0;
  30.  
  31.  
  32. for(int judge = 0; judge < scores[skater].length; judge++) {
  33.  
  34. //lowest score
  35. if(scores [skater] [judge] < min) {
  36. min = scores [skater] [judge];
  37. }
  38.  
  39. //highest score
  40. if(scores [skater] [judge] > max) {
  41. max = scores [skater] [judge];
  42. }
  43.  
  44. //How to print
  45. sum = sum + scores[skater][judge];
  46. System.out.print(scores[skater][judge] + "\t");
  47. }
  48.  
  49. //figuring out final scores
  50. sum = sum - min - max;
  51. double avg = sum / (scores[skater].length- 2);
  52. System.out.println();
  53. System.out.println("Average: " + df.format(avg));
  54. System.out.println();
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement