Due Date: Wednesday March 22/ Thursday March 23
This project should be your and only your work. Please do not discuss this with any of your classmates. If you need help contact TAs or the instructor.
This project will be a stand alone application that explores the way objects interact with each other. The idea is that we want to have a collection to store a list of students, and calculate their grades. For this project you will implement three classes in total: Student, CourseList, and GradeCalculator.
The Student class stores grades for one of the courses, let us say Java class. Thus the Student class should have two private fields representing the name, and the grade of the student. For simplicity, let us assume that grades will be integers. The Student Interface will give you more idea about what methods to implement for this class.
The CourseList will store information about a collection of students. Thus, it will have one private field of type ArrayList. The Interface should give you an idea about what methods to implement for this class.
The GradeCalculator class will be the driver class for this project. It will have a main method that will initialize an object of type CourseList, and add about 5 student objects to it and finally display the student names, their grades along with the class average.
Note: The TA may change the number of student objects added to the courselist object in your GradeCalculator class. Thus, your program should be generalized enough to work with any number of students.
Below are the methods and constructors your classes must implement.
Student class:
Constructor:
public Student(String name, int javaGrade)
public Student()
Methods:
public void updateJavaGrade(int newGrade)// Will change the old grade to the one that is
passed, hence information about previous grade
will be lost
public void updateName(String newName) // Will change the old name to the one that is passed,
hence information about previous name will be lost.
public int getJavaGrade()
public String getName()
public void toString() // Will print information about grades along with student name
CourseList class:
Constructors:
public CourseList() // Checklist: make sure you initialize the fields properly
Methods:
public void browseGrades() // should print all the information about the student grades
public double calJavaAverage() // should both return and display the average
grades for the class
public void addStudent(Student student) // should add the student objects to the collection
The browseGrade() method should print information in the following format:
StudentName StudentGrade
The class average is: xx.xx //Thus after displaying all the student grades it should also display the class average. The class average
should be limited to two decimal places.
The calJavaAverage() method should print information in the following format:
The class average is: xx.xx
Make sure that the class average you print is always upto 2 decimal places. (e.g., 23.455 would be printed 23.46 or 25.3243 would be printed 25.32, or 24.1 would be printed 24.10). Hint: You can use the DecimalFormat class.
GradeCalculator
This class will implement a main method that will create an object of type CourseList, and add about 5 students to the list.
It will also call the browseGrade() and calJavaAverage() method to print information about the student grades to the screen.
Checks
Since you are storing grades, you will need appropriate checks both in setter methods and constructors so that the information is stored properly. For instance that the grades should not be negative. I will let you handle the situation in which someone inputs a negative grade. Also make sure you have check for division by zero error.
Please document your code
You must document your code to get a full credit.
Program Compilation
Your program must compile and run.
Pledge
Every program submission for this class must include an Honor Code
pledge. Specifically, you must always include the following pledge statement in the header comment for
your program:
/****************************************************************************
*
* On my honor:
*
* - I have not discussed the Java language code in my program with
* anyone other than my instructor or the
teaching assistants
* assigned to this course.
*
* - I have not used Java language code obtained from another
student,
* or any other unauthorized source,
either modified or unmodified.
*
* - If any Java language code or documentation used in my program
* was obtained from another source, such as a text book or course
* notes, that has been clearly noted with a proper citation in
* the comments of my program.
*
*
* Your Name
* Your PID
****************************************************************************/
Failure to include this pledge in a submission is a violation of
the Honor Code.