CS 157 Spring 2002 Assignment 6 – Validation, Nested While loops (plus previous material!) 100 points
Assigned: 02/21/2002
Due: 03/14/2002 at the start of class (that seems like a long way off, but spring break is in there, and no lab on 2/28)
Pre-Lab (Do Before Lab): Bring a new disk. Plan out sequence of statements needed for program. This is another step up in complexity. Plan ahead!!
Main Assignment:
The
International Olympic Committee needs a program to calculate ice skaters’
scores during competitions. The program (illustrated with an example below)
first asks for the number of judges, then for first artistry, then for
technical merit, gets scores from each of the judges - the program should ask for and ensure that
it gets a valid score (between 0.1 and 6.0).. YOUR PROGRAM MUST USE A LOOP FOR
THIS VALIDATION (so that it does not go on until the most dim-witted judge
enters a valid score) – WITHIN (nested
inside) A LOOP TO GO THROUGH THE JUDGES. The skater’s artistry and technical
scores are calculated by subtracting the highest score and the lowest score on
the appropriate area from the total of all judges scores. The final total score
is the sum of artistry and technical totals. See example below.
Sample Interaction with the user (minus user
answers which are typed elsewhere):
Processing Skater
How many Judges?
Artistry Score from Judge 1 :
Invalid Score - please enter a value between 0.1 and 6.0:
Invalid Score - please enter a value between 0.1 and 6.0:
Artistry Score from Judge 2 :
Artistry Score from Judge 3 :
Invalid Score - please enter a value between 0.1 and 6.0:
Artistry Score from Judge 4 :
Artistry Score from Judge 5 :
Artistry Score from Judge 6 :
Artistry Score from Judge 7 :
Subtracting high: 6.0 and
low: 0.1 from total: 31.499999999999996
Artistry Score for Skater is:
25.4
Technical Score from Judge 1
:
Technical Score from Judge 2
:
Technical Score from Judge 3
:
Technical Score from Judge 4
:
Technical Score from Judge 5
:
Technical Score from Judge 6
:
Technical Score from Judge 7
:
Subtracting high: 5.7 and
low: 5.1 from total: 37.800000000000004
Technical Score for Skater
is: 27.000000000000004
Total Score: 52.400000000000006
Hand in:
Miscellaneous:
·
Please try to make
the output of your program like mine, to aid my grading. (but note that we
haven’t done anything yet with specifying how many decimal places to display)
·
You will need the SavitchIn.java file (still obtainable
from my WWW page - or from previous
weeks).
·
You can use dialog boxes if you prefer, but make sure
it doesn’t get in your way.
·
MAKE SURE YOUR
PROGRAM WORKS! (i.e. more than just removing compile errors). You can test your
program on the above example, but make sure you test it on other data as well -
I will! Your program needs to be able to handle any valid inputs, and catch
invalid values of the correct type (The SavitchIn functions catch invalid
values that are the wrong type (e.g. letters where numbers are needed).
·
If you have any
questions about the scoring scheme, please ask!!! Your calculations need to
meet the requirements of the task.
·
Put YOUR NAME, and
e-mail address in comments at the beginning of the program.
·
Remember: Indentation, meaningful variable names, and
meaningful comments. Weaknesses in any of these could result in points off. You MUST include comments that explain your
program in order to get full credit.