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):
- Total number of games:
- Total number of games scoring at least 70 points:
- Percentage of games scoring at least 70 points:
- Average game score:
- 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
Additional Questions
-
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?
Grading
- 2 points Header correct in .java file
- 5 points Loop
- 12 points 2 points for each statistic (lowest and highest score are separate stats)
- 2 points Comments in your code
- 2 points Jar file created/executes correctly, files named correctly
- 2 points Additional Questions
How to hand in the assignment
-
A file named yourlastname_lab4.jar, where yourlastname is your last name.
The .jar file should include these files: BasketballStats.java, BasketballStats.class and MANIFEST.MF.
- Your java file should have the appropriate header.
Follow these instruction to create yourlastname_lab4.jar.
-
Submit via Sakai yourlastname_lab4.jar by 23:59pm, Thursday February 28.
-
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.