# COMP 110-003 Spring 2013

## Lab 4

### 25 points

Assigned: Thursday, February 14
Due: Thursday, February 28

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 (via console, not message box) and outputs the following statistics (to the console, not message box):

1. Total number of games:
2. Total number of games scoring at least 70 points:
3. Percentage of games scoring at least 70 points:
4. Average game score:
5. Range of scores: lowest to highest (hint: define one variable for each)

The end of the input is indicated by the user entering a negative sentinel value. (See page 226 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 solve each statistic
• example: total number of games
• for each input score, increment games 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 and then move to problem two.
• You only need to write ONE loop

• What is the average number of hours per week you are putting into this class? (I know the last assignment was hard and took a lot of time)
• What have you found to be most useful for learning how to program?
• Is there anything you would want to change in the class to help you learn how to program better?

• 2 points Header correct in .java file
• 5 points Loop
• 12 points 2 points for each statistic (lowest and highest score are separate stats)