Problem D
Scores
Write a program that takes a sequence of real numbers, removes the three lowest numbers and prints out the sum of the remaining numbers.
An error message should be printed if the number of floats entered is $< 3$, but no other error handling is needed.
Input
The program recieves one line as input, a sequence $x = (x_1, x_2, \dots , x_n)$ of $n$ real numbers seperated by spaces.
In the tests, $x$ will be of length $n$, with $1 \le n \le 200$, where each $x_i$ will satisfy $0.0 \le x_i \le 100.0$ for $1 \le i \le n$, and each number $x_i$ will be given with at most one digit after the decimal point.
In the samples below, the first and only line of the input contains the sequence $x$.
Output
The output should consist of either:
-
The string “At least 3 scores needed!”, if fewer than three scores were input.
-
The string “Sum of scores (3 lowest removed): {$s$}” where $s$ is the sum of of all the numbers in the sequence $x$ except the lowest three, if three or more scores were input.
The sum your program outputs must be within $0.01$ from the correct answer.
Sample Input 1 | Sample Output 1 |
---|---|
1.1 |
At least 3 scores needed! |
Sample Input 2 | Sample Output 2 |
---|---|
1.1 2.2 |
At least 3 scores needed! |
Sample Input 3 | Sample Output 3 |
---|---|
1.1 2.2 3.3 |
Sum of scores (3 lowest removed): 0.0 |
Sample Input 4 | Sample Output 4 |
---|---|
2.3 4.5 1.1 7.8 3.4 5.6 |
Sum of scores (3 lowest removed): 17.9 |
Sample Input 5 | Sample Output 5 |
---|---|
-2.3 4.5 6.8 9.9 2.4 6.5 11.3 12.9 2.8 8.5 |
Sum of scores (3 lowest removed): 60.4 |