COSC 060 Introduction to Software Problem Solving
Fall 2008
Homework Assignment #3
"Aw, people can come up with statistics to prove anything...
Forfty percent of people know that."
-- Homer Simpson, Homer The Vigilante
Due: Wednesday, September 17th, 11:59PM CDT
Submit: Turn in your "Project3.java" using the turnin command
on Morbius.
Work may be completed in teams of two. The names of both partners must
appear in a comment block at the top of your file for credit to be given.
Grade Statistics
Storing and manipulating a database of grades takes a lot of work.
However, computers excel at the tedious computations necessary to
characterize simple lists of numbers.
Write a program that prompts for a list of integer grades
(0 - 100, inclusive). When the list is entered, print out the
following statistics: total grades, the breakdown of grades by letter
(both count and percentage), the highest and lowest grades in the list,
and the class average.
Example Runs
In the examples below, I use text in blue to distinguish the output of the program from the input I typed. This is
for purpose of clarity only; your program will not print text in different colors.
Example #1
Project 3 - Grade Statistics
Please enter a list of grades (0-100):
55 65 75 85 95 -1
Total number of grades = 5
Number of A's = 1 (20%)
Number of B's = 1 (20%)
Number of C's = 1 (20%)
Number of D's = 1 (20%)
Number of F's = 1 (20%)
Highest grade = 95
Lowest grade = 55
Class average = 75
Example #2
Project 3 - Grade Statistics
Please enter a list of grades (0-100):
90 91 94
97 100 -1
Total number of grades = 5
Number of A's = 5 (100%)
Number of B's = 0 (0%)
Number of C's = 0 (0%)
Number of D's = 0 (0%)
Number of F's = 0 (0%)
Highest grade = 100
Lowest grade = 90
Class average = 94
Example #3
Project 3 - Grade Statistics
Please enter a list of grades (0-100):
-1
Total number of grades = 0
Notes
Note that the list is completed when either the end-of-file marker
is reached (Ctrl-D or Ctrl-Z, depending on your system,) or when a grade
is entered that is out of range, (like -1).
If the list is empty, print only the total, and skip the other lines
of output. This avoids meaningless highs and lows, or division by zero
when calculating the average or the precentages.
Letter grade breakdowns follow the same scheme as this course:
90% and above is an 'A', 80% and above is a 'B', 70% and above is a 'C', 60%
and above is a 'D'. Below 60% is an 'F'.
All calculations for this assignment should be performed with
integer precision; please do not use float
or double type variables, or you will get different answers
from mine.
It is not necessary to store the list of grades to complete
this assignment. Each of the statistics required can be calculated
simply by examining the next grade in the sequence and updating the
relevant counts and totals. For those of you with more advanced experience,
it would be needlessly complex to store all of the grades in an array
or some other data structure.
The Professor has provided a reference implementation for you to compare
against. Change to directory ~brylow/cosc060/Demos/ on Morbius, and
run java Project3.
Back
[Revised 2008 Sep 09 17:28 DWB]