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 Note that this program is simpler than the one in How To 7.1 since
8 we need not worry about the possibility of having too many scores.
9 */
10 public class ScoreAnalyzer
11 {
12 public static void main(String[] args)
13 {
14 Student fred = new Student();
15 System.out.println("Please enter values, Q to quit:");
16 Scanner in = new Scanner(System.in);
17 while (in.hasNextDouble())
18 {
19 fred.addScore(in.nextDouble());
20 }
21
22 int pos = fred.minimumPosition();
23 if (pos == -1)
24 {
25 System.out.println("At least one score is required.");
26 }
27 else
28 {
29 fred.removeScore(pos);
30 double total = fred.sum();
31 System.out.println("Final score: " + total);
32 }
33 }
34 }
35