CS 157 Spring 2001                       Assignment 12 – Parallel Arrays and Strings                                                           100 points

 

Assigned: 04/18/2001

Due: 04/30/2001 at the start of class.

Pre-Lab (Do Before Lab): Bring an empty (or nearly empty) disk (keep any .c files you create, but other files can be deleted). Plan out sequence of statements needed for program.

Main Assignment:

                USA Skating wants you to write a program for them that will partially keep track of skaters for a competition. Each competition has a short program worth 40% of the overall score, on which each skater will score between 0 and 30, and a long program worth 60% of the overall score, on which each skater will also score between  0 and 30. Your program should 1) ask the user for how many skaters are forthcoming – validate that the number is greater than 0 and no more than 50; 2) should get info about each skater – including name (of to 15 chars), short program score, and long program score, (validate all scores) storing each in an array; 3) calculate the skaters overall score, storing that in an array; 4) put information into order by overall score; and 4) present the information in that order (see simplified example below).

Details:

1)       Use parallel arrays to hold information about skaters. Your arrays can be limited in size to 50.

2)       Any known sort functions needs to be adjusted to handle parallel arrays. Make sure that each skater keeps all of their own scores!!

3)       This is an exercise in using C parallel arrays and strings – use them.   

4)       With what we know, our reading of strings is somewhat limited. Assume that the user will enter a valid name – no more than 15 chars, and no spaces within the name.

5)       The skater’s score (0-30) is calculated from judges’ scores, we have left that part out to keep the program from getting too complicated. You just ask the user for the scores.

6)       You should be able to figure out the calculation for total score by yourself, given the info above plus that the maximum possible score should be 100. It’s not trivial though. Think about it in advance!

7)       Your greeting to the program user should use your name instead of “YOURNAMEHERE” (see below) but can alter the rest of the greeting to be less silly if you like.

8)       Continue, as always, to break the program down into functions. Certainly the sort and displaying output should be functions. Others may be as well.

 

Sample interaction with the user:

      Welcome to YOURNAMEHERE’s Super De Duper Skating Calculator!

How many skaters to calculate? 

Please enter your next number between 1 and 50: 55

I'm sorry, your numbers must be between 1 and 50: 3

Name?

    Please enter the skaters name (no more than 15 chars; no spaces) harding

Short Program Score?

Please enter your next number between 0.0 and 30.0: 105.0

I'm sorry, your numbers must be between 0.0 and 30.0: 30.0

Long Program Score?

Please enter your next number between 0.0 and 30.0: 20.0

Name?

    Please enter the skaters name (no more than 15 chars; no spaces) kwan

Short Program Score?

Please enter your next number between 0.0 and 30.0: 25.9

Long Program Score?

Please enter your next number between 0.0 and 30.0: 32

I'm sorry, your numbers must be between 0.0 and 30.0: 29.0

Name?

    Please enter the skaters name (no more than 15 chars; no spaces) lipinski

Short Program Score?

Please enter your next number between 0.0 and 30.0: 20

Long Program Score?

Please enter your next number between 0.0 and 30.0: 25

 

                  **Final Results**

 

Total        Short Program      Long Program      Name

=====        =============      ============        ====

 92.5            25.9            29.0         kwan

 80.0            30.0            20.0         harding

 76.7            20.0            25.0         lipinski

 

Hand-in:

     1) Listing of the program

2)       Disk with  .c source file plus .exe executable file). NAME YOUR PROGRAM FILE yourlastname12.c;

 

Miscellaneous:

1) Make your program work like shown above. If you have any questions about what should be done, please ask!!

2) MAKE SURE YOUR PROGRAM WORKS! (i.e. more than just removing compile errors). Test it more than once - I will! Your program needs to be able to handle any inputs including catching invalid inputs.

3) Remember: Indentation, meaningful variable names, symbolic constants, 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. Also make sure you put YOUR NAME, section, and e-mail address in comments at the beginning of the program.

                4) This program is due 4/30; assignment 11 is due on 4/23. This means that we will have two assignments spread over three labs (4/12, 4/19, and 4/26) but that programs will overlap. Try to get to part of this assignment in 4/19 lab.