Introduction to Computer Science II by James Tam Return to the course web page

CPSC 233: Assignment 2(Worth 3%)

 

Writing a grade tabulator for CPSC 233

The requirements for this assignment are identical to the ones for Assignment 1, except that you must now employ multiple classes.  You will have to write a "Driver" class (that contains the main method) as well as another class "GradeTabulator" that implements most of the operations described assignment 1.  It is likely that your main method will now do little more than instantiate an instance of GradeTabulator as well as calling the methods of this class.  Roughly the driver will look something like this:

class Driver

{

        public static void main (String [] args)

        {

                GradeTabulator tabulatorF2003 = new GradeTabulator ();

                tabulatorF2003.displayIntroduction();

                    etc.

                // You may or may nor wish to have the loop in here that allows the user to continue performing calculations.

        }

}

 

You cannot implement a solution to Assignment 2 that employs only a single class nor can you implement a solution that uses static methods (aside from the main method and the methods contained in the tio library). 

As a guideline here are some of the methods that you may wish to implement in class GradeTabulator:

  1. public void displayIntroduction (): As the name implies this method includes a number of output statements.  These statements describe what the program does and how it works.
  2. public double determineGPA () : This method prompts the user to enter in all the component GPA's and calculates the overall GPA as a the sum of the weighted component GPA's.  The resulting value "overallGrade" is then returned back to the main method in the Driver class.
  3. public String determineLetterGrade (double overallGrade): I implemented this method as a series of decision-making if, else-if constructs.  It takes as input the overall term GPA calculated by method #2 and returns back to the main method a String which is the letter grade equivalent of the GPA.
  4. public void displayGrades (double overallGrade, String letterGrade): The inputs to this method are the overall term GPA and letter grade which are displayed onscreen by some output statements in the method.
  5. public void displayEndMessage (): A very short method that displays a parting message when the user decides that he or she no longer wishes to tabulate any more grades and wants to quit the program.
Note: Your implementation may of course differ but just make sure that each method performs a well-defined task and that the amount of code in each method is fairly balanced (e.g., don't just write one method that does all of the above operations).

 

Grading

Assignments will receive a grade of "A" if it fulfills all of the above requirements.  Your solution does not have to perform extensive error checking to get full credit (e.g., at this point it's acceptable if your program crashes if the person enters a character instead of a real number).   

 

Other submission requirements

1. Good coding style and documentation:  They will play a role in determining your final grade for this assignment.  Your grade can be reduced by a letter step e.g., "A" to "A-" for poor programming style.

2. Data to run for the test cases:  You must run your program in the typescript with the following data:

Assignment 1 GPA 4
Assignment 2 GPA 4
Assignment 3 GPA 3.3
Assignment 4 GPA 2.3
Assignment 5 GPA 2.7
Midterm GPA 3
Final GPA 2

Assignment submissions that are not run with these inputs will be reduced by a letter step.  

Note: You need to fulfill both submission requirements (otherwise you can end up losing 2 letter steps if you miss both requirements e.g., "A" to "B+").

 

Sample Executable

You can out the sample byte code program called "GradeTabulator.class" which can be found in Unix in the directory: /home/233/assignments/assignment1+2

 

New Concepts to be applied for the assignment

  1. Writing programs that consist of more than one class