Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Anthony Conner
- //Skater Scores
- //4-25-19
- import java.text.DecimalFormat;
- public class Program {
- public static void main(String[] args) {
- //Scores
- double [] [] scores = { {5.6, 3.5, 5.9, 5.4, 5.1},
- {4.4, 5.4, 5.4, 5.8, 5.9},
- {4.5, 2.4, 4.3, 5.2, 4.5},
- {4.4, 5.2, 5.8, 4.9, 5.6},
- {5.3, 4.2, 5.5, 4.9, 4.9},
- {5.9, 5.6, 0.7, 4.4, 6.0},
- {5.1, 5.8, 3.2, 4.9, 2.8}};
- //Helps round scores to 1 decimal place
- DecimalFormat df = new DecimalFormat("#.0");
- //Doubles to get the scores
- for(int skater = 0; skater < scores.length; skater++) {
- System.out.println("Scores for Skater #" + (skater + 1) + ":");
- double sum = 0;
- double min = 6;
- double max = 0;
- for(int judge = 0; judge < scores[skater].length; judge++) {
- //lowest score
- if(scores [skater] [judge] < min) {
- min = scores [skater] [judge];
- }
- //highest score
- if(scores [skater] [judge] > max) {
- max = scores [skater] [judge];
- }
- //How to print
- sum = sum + scores[skater][judge];
- System.out.print(scores[skater][judge] + "\t");
- }
- //figuring out final scores
- sum = sum - min - max;
- double avg = sum / (scores[skater].length- 2);
- System.out.println();
- System.out.println("Average: " + df.format(avg));
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement