Sie sind auf Seite 1von 3

COMP 108 Orientation to Computer Science

Programming Project #3 Grade Book (30 points)


Due December 9, 2014
Part 1
Create a command line Java program to input and track student grades. The key to
developing this program will be a sentinel loop that will input student scores until
the sentinel value of -1 is entered to indicate the loop should exit and the results
should be output. The user will enter a series of test scores between 0 and 100, where
a score less than 100 and greater than or equal to 90 is an A, a score less than 90 and
greater than or equal to 80 is a B, and so on until a score less than 60 and greater than
or equal to 0 is an F. As each grade is entered, count the number of A's, B's, Cs, Ds
and Fs earned so you can list the grade totals after the loop exits. You will also need
to track the total number of scores entered and the total points earned so you can
compute averages after the loop completes.
While the user is entering scores, output a message like "A score of 72 is a C", but the
real action occurs AFTER the user enters a -1 score and the program exits the loop.
At this point, output a report along the following lines:
Total number of A's:
Total number of B's:
...
Total number of F's:

X
Y
Z

Total number of scores input: XX


Average class score:
YY.YY
Average class grade:
A or B or ...

Obviously the number of scores input (XX) should match the totals of A's + B's + C's
etc.
Be sure to calculate the average class score (YY.YY) using the double data type. If
the average is 82.45, I DO NOT want you to round the average to 82 or 82.0. As for
the average class grade, use the average class score, when it is 82.45 that means it is a
B.

Break large problems into smaller pieces!


Sometimes it is useful for beginners to complete a smaller, simpler program before
tackling the full project. Start with an easy program that only completes part of the
project. Name your project Project3 and your main class GradeBook. Always use
class, variable and project names that clearly describe what you are creating.
Start Here:
Write a program to input one average class score and then use some sort of if-else or
switch to print the average class grade.
Add A Loop:
Add code to the beginning of your program that loops and allows the user to input
scores until a -1 is entered to exit the loop. The loop should include code which
updates your total variables like total number of As, total number of Bs, total
number of points, and total number of scores entered. Be sure this loop is BEFORE
the code that prints the average class grade.
Dividing a larger problem into smaller sub-problems is an important technique in
computer programming.
Please Design First
It is good practice to design your software on paper first, before you actually write the
code. Here are some design tasks you should complete before starting:

Write out a list of variables you think you will need (e.g. int totalAs; // count of
A scores)
Flow chart (or Pseudo code) the selection statement(s) needed to determine if a
score is in the range of an A, B, C...
Flow chart (or Pseudo code) the loop, include the check for -1 input and update
of total variables

In other words, have some idea about HOW you are going to solve the problem,
BEFORE you try to solve the problem.

Part 2 GUI Revision (5 points Extra Credit)


Be sure to complete Part 1, run it, test it, and make sure it runs perfectly before even
attempting Part 2.
Read the GUI Program Input and GUI Program Output slideshows which were posted
for Project 2. Create a second version of the program that uses
JOptionPane.showInputDialog boxes to input the test scores and
JOptionPane.showMessageDialog boxes to output the results. This second version of
the program should make the same calculations and give the same results, so much of
the code will just be copied and pasted from Part 1, just use a GUI for the input and
output of the data.
I would create Part 2 by adding a NEW main class java file named GradeBookGUI
to the existing project. Do not change or delete your Part 1 code, I want to see both
programs.

Das könnte Ihnen auch gefallen