CS 157 Spring 2003               Assignment 8 – Nested Loops, Validation – along with some previous topics 

100 points

 

Assigned: 03/19/2003

Due: 03/26/2003 (at the start of class – as will be the normal case)

 

Pre-Lab (Do Before Lab):  Bring an empty (or nearly empty) 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.  You will build upon the capabilities provided by the Skater class (available on my www page under assignments). The program (illustrated with an example below) first asks for the number of judges.  It should validate that the number of judges is acceptable – between 6 and 10.  It should then immediately establish the number of judges via the Skater class’s setNumJudges method. Then, the program should ask for the current skater’s name and country, and then create a Skater.  Next, you will need the skaters scores - first for artistry assigned by each of the judges, then for technical merit assigned by 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).  The Skater object will hold the scores, just as ChessPiece objects held their color and rank. You can put a score into an object using the setNthArtScore and setNthTechScore methods. You can get a score out using the getNthArtScore and getNthTechScore methods. 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.  The calculations can largely be done using capabilities of the Skater class.

 

·        You program will use the capabilities of the Skater class provided on the assignments page on my www site.  Note, that on my WWW page, besides the java file, there is a documentation file. This is where you should learn about the class (besides what I said above). 

·        Some warnings about things to look for: 1) setNumJudges is a static method !!! 2) the Skater class considers the Nth score to start with 0 –e.g. with 6 judges, the N’s to use would be 0-5

·        Change the package statement in the file to be appropriate for what package you put it in, otherwise you should not have to modify the file.

·        You will still need the Keyboard file (still obtainable from my WWW page  - or you may still have it on disk). 

·        Format the data so that scores have one decimal place!!!

·        Put your name, e-mail address, and date in comments near the top (e.g.  /* Your Name */). 

·        Also, comment any significant code to document it (each loop, each if, and each significant calculation should have a comment).

·        Indent code following standard conventions (indent to show that something is “inside” or “part of” the preceeding code (e.g. inside if’s or loops, or statements continued on a new line). 

 

Compile the program and remove any errors. Ensure that the program runs correctly. It should run on any set of inputs (test it on more than the example below!!, I will!!).

               To avoid needless long waits, I recommend doing this on the c: drive, then upon completion, copying it to the a: drive, testing it there, creating an extra backup for yourself, then deleting it from the c: drive.

 

Hand in:

 

 


Sample Interaction:

How many judges working?

12

I'm sorry, please enter a number of judges between 6 and 10

6

What is the skater's name?

Michelle Kwan

What is the skater's country?

USA

Artistry Score From Judge #1

6.0

Artistry Score From Judge #2

6.1

I'm sorry, please enter a value between 0.1 and 6.0:

6.05

I'm sorry, please enter a value between 0.1 and 6.0:

6.0

Artistry Score From Judge #3

5.9

Artistry Score From Judge #4

5.2

Artistry Score From Judge #5

5.8

Artistry Score From Judge #6

6.0

Artistry Score for Michelle Kwan: 23.7

 

Technical Score From Judge #1

5.5

Technical Score From Judge #2

5.8

Technical Score From Judge #3

-6

I'm sorry, please enter a value between 0.1 and 6.0:

5.0

Technical Score From Judge #4

5.8

Technical Score From Judge #5

5.5

Technical Score From Judge #6

5.6

Technical Score for Michelle Kwan: 22.4

 

Total Score for Michelle Kwan: 46.1