COMP 110-003 Fall 2008
Lab 4
25 points
Assigned: Friday, September 19
Due: Friday, September 26 Wednesday, October 1 by 2:00pm
Description
Lab 4 will give you practice with writing a loop. Write a program that reads in a
list of UNC basketball scores (nonnegative integers!) one at a time from the user and
outputs 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 and highest
The end of the input is indicated by the user entering a negative sentinel value.
See p. 183 (4th edition) or p. 207 (5th edition) 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 on to the rest of the statistics one at a time, testing
that each one of them works properly.
- You only need to write ONE loop
Additional Questions
-
What is the average number of hours per week you are putting into this class?
-
What have you found to be most useful for learning how to program so far this semester?
-
Would you find having more in-class written worksheets to be helpful?
How to turn in the assignment
- Name your class
BasketballStats
and your Java source file BasketballStats.java
.
- Make sure you put the standard program header at the top of your code
and modify the header appropriately.
- Follow the instructions for creating a JAR file named
yourlastname_lab4.jar
containing your Java source code.
- Send me an email with the subject line
COMP110 Lab4 yourlastname
with the following attachments:
yourlastname_lab4.jar
(where yourlastname
is your last name),
which includes your BasketballStats.java
source file
yourlastname_lab4.txt
(or .doc
),
which has your answers to the Additional Questions and a short write-up of questions
you had and/or problems you encountered while doing this assignment
(make sure to include the standard writing assignment header)
Print a copy of your code (BasketballStats.java
) and hand it in at the beginning
of class on the due date.
If you do not follow these instructions you will not get credit for the lab.
Please let me know if you are having any problems with the assignment submission process.
Grading
- (2 points) Pledge header in both the
.java
file and the
.txt
(or .doc
) file, with fields changed appropriately
- (5 points) Loop
- (12 points) 2 points for each statistic (lowest and highest score are two separate statistics)
- (2 points) Comments in your code
- (2 points) Printed copy of your
BasketballStats.java
code
- (2 points) Additional Questions