1 import java.util.Scanner;
2
3 /**
4 This program computes a final score for a series of quiz scores: the sum after dropping
5 the lowest score. The program adapts the algorithm for computing the minimum.
6 */
7 public class ScoreAnalyzer
8 {
9 public static void main(String[] args)
10 {
11 Student fred = new Student(100);
12 System.out.println("Please enter values, Q to quit:");
13 Scanner in = new Scanner(System.in);
14 while (in.hasNextDouble())
15 {
16 if (!fred.addScore(in.nextDouble()))
17 {
18 System.out.println("Too many scores.");
19 return;
20 }
21 }
22
23 int pos = fred.minimumPosition();
24 if (pos == -1)
25 {
26 System.out.println("At least one score is required.");
27 }
28 else
29 {
30 fred.removeScore(pos);
31 double total = fred.sum();
32 System.out.println("Final score: " + total);
33 }
34 }
35 }
36