Project 4:  A Simple Course Grade Program

40 points 

See the "Hints" section clear at the end for a little help on this assignment.

This is one of four major individual assignments that you are required to complete in this class. You MUST design and code this project on your own. You can ask for debugging help, particularly from the tutors, TA or instructor, but this project is to be your own work. The project relies on knowledge and skills that you will develop in Recitation Laboratories 10-12. If you are having trouble with these recitations after your in-class session, please be sure that you come to the lab at another time and sit down with a tutor.


Objectives: Hand-in Requirements: Overview: You are going to write a program that keeps track of a college student's grades in a course.  Not only will you be able to store grades into whatever grade category you want to, but also find out what you need to make on the final for a specific final average, find the type of grade you performed best in, and print your average.

Write a super class (Average.java) that will represent an Average for a grade category.  This super class will store the numerator and denominator for an average.  It will also store the name of the grade category and the weight of that category for the course.  For example suppose you have made a 15 out of 15, a 18 out of 20 and a 23 out of 25 for your projects.  The projects are worth 15% of your overall average.  By adding the numerators 15+18+23 = 56 and denominators 15+20+25 = 60, you can find the project average 56/60 = 93 and the partial average in relationship to the course average 56/60*15(weight) = 14.  This means out of your final average 14 points were earned by your project grade.  This means we don't have to store each individual grade in a category, just keep adding any grade earned to the numerator and the highest possible score for that grade to the denominator.

Write two classes that will inherit the Activity class: one will be used when the category has multiple grades like our projects, recitations and exams.  The other will be used when the category has only one grade like our final exam.  

The Course class is created for the course we are maintaining.  It will perform most of the work needed to maintain our grades.

Finally, the  client code will be provided for you.  You can see what the methods will do and can use this as a means for testing your program.  For extra credit you can add the ability to read data from a text file before the main menu starts and write data to the text file before the program ends.  This will maintain grades between runs.  (Makes this a very usable program).

Specifics of the project:

Average Class
   private data members:

   methods:

Multigrade Class extends Average
   private data members: none
   methods:

Singlegrade Class extends Average
   private data members: none
   methods:

Course Class
   private data members:

   methods:

Notes:
For computation of partial grades if you divide an integer by an integer you don't get an accurate result.  You need to type cast to double before you divide.  If you want to return an integer you need to type cast a double to int.

Client Code:


public class Project4Test {
   public Project4Test() {}

   public static void main(String[] args) {
      Course cs1713 = new Course("CS 1713");
      cs1713.addMultiGradeType("Projects",15);
      cs1713.addMultiGradeType("Recitations",15);
      cs1713.addMultiGradeType("Exams",40);
      cs1713.addSingleGradeType("Final Exam",30);

      char response;
      int n;
      int d;
      String group;
      do {
         group = "";
         response = 'a';
         System.out.println("Would you like to: enter the number of your choice: ");
         System.out.println("Add a grade to:");
         System.out.println(" 1) Projects");
         System.out.println(" 2) Recitations");
         System.out.println(" 3) Exams");
         System.out.println(" 4) Final Exam");
         System.out.println("5) Print Current Partial and Total Averages");
         System.out.println("6) Find out what you need to make on the Final Exam");
         System.out.println("7) Find out for which type of grade you did the best");
         System.out.println("0) Quit");
         response = Keyboard.readChar();
         switch (response) {
            case '1' :
                group = "Projects";
                break;
            case '2' :
                group = "Recitations";
                break;
            case '3' :
                group = "Exams";
                break;
            case '4' :
                group = "Final Exam";
                break;
            case '5' :
                System.out.println(cs1713);
                cs1713.printAverage();
                break;
            case '6' :
                System.out.println("Enter the grade you want to earn for the course");
                int desiredScore = Keyboard.readInt();
                System.out.println(cs1713.testFinal(desiredScore));
                break;
            case '7' :
                System.out.println(cs1713.findMax());
                break;
         }
         if (group.compareTo("")!=0) {
            System.out.println("Enter the grade");
            n = Keyboard.readInt();
            System.out.println("Enter the highest possible grade");
            d = Keyboard.readInt();
            cs1713.addGrade(group,n,d);
         }
      } while (response != '0');
   }
}

Question:
In the course class we could have created an array for all of the grade types, not just the multigrades.  Write code that would create a four element array of either multigrade or a singlegrade.  Rewrite the code for addSingleGradeType and addMultiGradeType to reflect how to add either type of element to the same array.

Hints:
(I'm trying to answer some of the questions that have arisen.)

  1. You have been given the class Project4Test (in the box above), and you should use it. It is permissible to make minor changes to this class and even to the requirements if necessary.
  2. The Project4Test class creates a single instance of the Course class, which is the most complicated class in the project. From the Project4Test class, one only calls methods in the instance cs1713 of the Course class. (Well, there's also the Keyboard class.)
  3. Inside the Course class, there should be a single fixed-size array of the Multigrade grade class (3 array elements are enough). Three instances of Multigrade are created and inserted into this array.
  4. There is also a single instance of the Singlegrade class declared inside Course.
  5. Both Multigrade and Singlegrade extend the Average class, so a method such as addGrade (which is in Average) can also be called from either of these extensions of Average.
  6. The method addGrade in Course will in turn call the proper addGrade in one of the three instances of Multigrade or in the single instance of Singlegrade. In case addGrade calls one of the three instances of Multigrade, you should use the inMulti method to use the String giving the group to get the proper index in the array of Multigrade objects.
  7. The Average class is fairly simple. It uses a tricky way to keep track of the average by keeping track of the total number of points earned and the total number of possible points. To add a grade, one just adds in the points earned and the possible points to get new totals. Individual grades are not available. In case there are no grades recorded (0 points earned and 0 points possible), you need to separately return 0 for the average, you can't divide 0 by 0.
  8. Assuming that the getPartialAverage method of Average works correctly, the compareTo method of Multigrade can just do a compare without taking zeros into account in any special way. This compareTo is then used inside the Course class to find the instance of Multigrade with the highest partial average.
  9. The methods tryScore of the Singlegrade class and testFinal of the Course class are really obscure and difficult to understand. Rather than giving elaborate hints, I recommend that you use your own interpretation, or else just leave them unimplemented.

email type-o reporting to mdoderer@cs.utsa.edu