COMP 110-001: Introduction to Programming, SSI'15
Lab 4
25 points
Assigned: Tuesday, May 26, 2015
Due: Thursday, May 28, 2015 by 11:59pm (EDT)
Description
Lab 4 is to practice writing loop statements. Write a program to read in a list of UNC basketball scores (nonnegative integers!), one at a time from the user (via the console, not a message box), and outputs the following statistics (to the console, not a message box):
- Total number of games:
- Average game score:
- Total number of games scoring at least 90 points:
- Percentage of games scoring at least 90 points:
- Range of scores: lowest to highest (hint: define one variable for each)
The input is ended by the user entering a negative sentinel value. (See page 227 for details). Note that the sentinel value is not used in computing the highest, lowest or average game score.
Suggestions for completing the assignment
- write pseudocode for how you would do each statistic
- For example: computing the total number of games
- Initialize the total number to be 0, then for each input score, increment the number of games by one
- Determine the variables you will need to hold the data, and figure out the type for each variable
- Declare and initialize each variable
- Determine what type of loop you are going to write
- Start with the first problem (total number of games) and write your loop to compute the total number of games. When your loop is ended, output the total number of games. Make sure this works and then your can move to the second problem.
- You only need to write ONE loop
Additional Questions
- Have you met any difficulties to finish this lab? What difficulties?
- Do you want me to make some changes in this class to help you learn better about programming? What kind of changes?
Grading
- 2 points Correct header in .java file
- 5 points Loop
- 12 points 2 points for each statistic (lowest and highest scores 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
- Add a file named yourlastname_lab4.txt, where yourlastname is your last name, to answer the additional questions; or put your answers in the comment box on Sakai.
- 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. If you have yourlastname_lab4.txt, please also include it in the jar file.
- Your java file should have the appropriate header.
Follow these instructions to create yourlastname_lab4.jar.
- Submit your jar file on Sakai by 11:59pm Thursday, May 28, 2015.
-
If you do not follow these instructions you will not get credit for this lab. Please let
me know if you are having any problems about this assignment.