Advertisement
Guest User

judging

a guest
Feb 6th, 2013
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.91 KB | None | 0 0
  1. import java.util.InputMismatchException;
  2. import java.util.Scanner;
  3. import java.util.Arrays;
  4.  
  5. public class judging
  6. {
  7.     public static void main (String [] args)
  8.     {
  9.         int n = 8;
  10.         double [] scores = new double[n];
  11.         double score;
  12.         String contestant, again = "Y";
  13.         Scanner scanner = new Scanner(System.in);
  14.        
  15.        
  16.        
  17.         while (again.equals("Y"))
  18.         {
  19.            System.out.print("What is the name of the contestant? ");
  20.            contestant = scanner.nextLine();
  21.            
  22.            getData (scores, n, scanner);
  23.            score = calculateScore ( scores, n);
  24.            
  25.            System.out.print("The contestant's is " + contestant + ". Their score totaled " + score + ".");
  26.            System.out.println("Scores " + scores[0] + " and " + scores[n-1] + " were omitted per organization regulations.");
  27.            
  28.            again="n";
  29.            System.out.println("");
  30.            System.out.print("Would you like to judge another contestant? ");
  31.            again=scanner.next();
  32.            again= again.toUpperCase();
  33.            scanner.nextLine();
  34.                        
  35.            if( (char) again.charAt(0) == 'Y')
  36.                again="Y";
  37.             else
  38.                 System.out.println("Goodbye.");
  39.            
  40.              
  41.            
  42.         }
  43.     }
  44.  
  45.  
  46.    
  47.     public void setScores(double [] scores)
  48.     {
  49.         this.scores = scores;
  50.     }
  51.    
  52.     public double [] getScores()
  53.     {
  54.         return scores();
  55.     }
  56.    
  57.     public static void inputScores ()
  58.     {
  59.        
  60.        
  61.     }
  62.          
  63.    
  64.     public double calculateScore()
  65.     {
  66.         double sum=0, subtract;
  67.        
  68.         Arrays.sort (scores);
  69.         subtract = scores[0]+ scores[n-1];
  70.        
  71.         for (int i=0; i < n; i++)
  72.         {
  73.             sum += scores[i];  
  74.         }
  75.  
  76.         return sum -= subtract;
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement