COMP 110 Summer 2012
Lab 4
Description
Lab 4 will give you practice with writing a loop. Write a
program to read in a list of UNC basketball scores (nonnegative
integers!) one at a time from the user and then output the
following statistics:
- Total number of games
- Total number of games scoring at least 90 points
- Percentage of games scoring at least 90 points
- Average game score
- Range of scores: lowest to highest
The end of the input is indicated by the user entering a
negative sentinel value. (See page 207 for details). Note that
the sentinel value is not used in computing the highest, lowest
or average game score.
Suggestions for starting the assignment
- Write pseudocode for how you would compute each statistic
- Example: total number of games:
- create a counter for the number of games
- for each input score, increment the counter by one
- Determine the variables you will need and figure out the type of each variable
- Define and initialize each variable
- Determine what type of loop you are going to write
-
Start with statistic number one (total number of games) and
get your loop to compute the total number of games. When
you end your loop, output the total number of games. Make
sure this works before moving to the next statistic.
- You only need to write ONE loop.