Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.InputMismatchException;
- import java.util.Scanner;
- import java.util.Arrays;
- public class judging
- {
- public static void main (String [] args)
- {
- int n = 8;
- double [] scores = new double[n];
- double score;
- String contestant, again = "Y";
- Scanner scanner = new Scanner(System.in);
- while (again.equals("Y"))
- {
- System.out.print("What is the name of the contestant? ");
- contestant = scanner.nextLine();
- getData (scores, n, scanner);
- score = calculateScore ( scores, n);
- System.out.print("The contestant's is " + contestant + ". Their score totaled " + score + ".");
- System.out.println("Scores " + scores[0] + " and " + scores[n-1] + " were omitted per organization regulations.");
- again="n";
- System.out.println("");
- System.out.print("Would you like to judge another contestant? ");
- again=scanner.next();
- again= again.toUpperCase();
- scanner.nextLine();
- if( (char) again.charAt(0) == 'Y')
- again="Y";
- else
- System.out.println("Goodbye.");
- }
- }
- public void setScores(double [] scores)
- {
- this.scores = scores;
- }
- public double [] getScores()
- {
- return scores();
- }
- public static void inputScores ()
- {
- }
- public double calculateScore()
- {
- double sum=0, subtract;
- Arrays.sort (scores);
- subtract = scores[0]+ scores[n-1];
- for (int i=0; i < n; i++)
- {
- sum += scores[i];
- }
- return sum -= subtract;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement