Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Arrays;
- public class DivingScore
- {
- public static void main(String []args)
- {
- Scanner kb = new Scanner(System.in);
- String[] judge = new String[7];
- String[] diver = new String[4];
- double[] finalScore = new double[4];
- double[] diveDifficulty = new double[7];
- double[][] diverScore = new double[4][7];
- fillArray(judge, diver, diveDifficulty, diverScore,finalScore);
- }
- public static void fillArray(String[] judge, String[] diver, double[] diveDifficulty, double[][] diverScore, double[] finalScore)
- {
- double diveDiff = 0;
- Scanner kb = new Scanner(System.in);
- for(int i = 0; i < 7; i++)
- {
- System.out.println("Input the judges name");
- judge[i] = kb.nextLine();
- }
- for(int j = 0; j < 4; j++)
- {
- System.out.println("Input the divers name");
- diver[j] = kb.nextLine();
- }
- for(int k = 0; k < 7; k++)
- {
- System.out.println("Input the dive difficulty");
- diveDifficulty[k] = kb.nextDouble();
- }
- for(int l = 0; l<4; l++)
- {
- for(int m = 0; m<7; m++)
- {
- System.out.println("Judge " + judge[m] + " enter the scores for " + diver[l]);
- diverScore[l][m] = kb.nextInt();
- }
- }
- findSmallest(diverScore);
- findLargest(diverScore);
- System.out.println();
- System.out.println("Judges");
- System.out.println(Arrays.toString(judge));
- System.out.println("Divers");
- System.out.println(Arrays.toString(diver));
- System.out.println("Dive Difficulty");
- System.out.println(Arrays.toString(diveDifficulty));
- System.out.println("Diver's Scores");
- for(int x = 0; x < 4; x++)
- {
- System.out.println(Arrays.toString(diverScore[x]));
- }
- calcScore(diverScore, diveDifficulty, finalScore,diver);
- awardMedal(finalScore, diver);
- }
- public static void findSmallest(double[][] diverScore)
- {
- int smallOne = 0;
- int smallTwo = 0;
- for(int i = 0; i<4; i++)
- {
- for(int j = 0; j<7; j++)
- {
- if(diverScore[i][j] < diverScore[i][j-1])
- {
- smallOne = i;
- smallTwo = j;
- }
- }
- diverScore[smallOne][smallTwo] = 0;
- }
- }
- public static void findLargest(double[][] diverScore)
- {
- int largeOne = 0;
- int largeTwo = 0;
- for(int i = 0; i<4; i++)
- {
- for(int j = 0; j<7; j++)
- {
- if(diverScore[i][j] > diverScore[i][j-1])
- {
- largeOne = i;
- largeTwo = j;
- }
- }
- diverScore[largeOne][largeTwo] = 0;
- }
- }
- public static void calcScore(double[][] diverScore, double[] diveDifficulty, double[] finalScore, String[] diver)
- {
- double temp = 0;
- double temp2 = 0;
- for(int i = 0; i<4; i++)
- {
- for(int j = 0; j<7; j++)
- {
- temp = temp + (diverScore[i][j] * diveDifficulty[j]);
- if(temp > diverScore[i-1][j-1] * diveDifficulty[j-1])
- {
- diver[i] = diver[i] + " " + temp;
- }
- }
- }
- }
- public static void awardMedal(double[] finalScore, String[] diver)
- {
- System.out.println(Arrays.toString(diver));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement