Create a class ProgramStudent solution

$14.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

Create a java project.

Situation: Students in a certain degree program must take four courses, Intro, Theory, Practical I, and Practical II.  In each they receive a grade from 0.0 to 4.0. 

☑ Create a class ProgramStudent to represent these students, which has last name, first name, ID number, and a grade for each of the four courses (think about what types are appropriate for these instance variables).  (You only need one ProgramStudent class!)

☑ Add a method to the class

public void aceIntro()
in this method,

·          print out a message saying that the student aced the Intro course, 

·         and set the instance variable for the grade for Intro to 4.0. 

☑ Write three more methods for acing the other courses, doing the same kind of thing

☑ Then write four more, similar, methods for failing each of the courses (grade for fail is 0).

☑ Add a toString which returns something like

Holmes, Sherlock (ID#44221) — Program GPA: 4.0
There are several ways to do this. You can do the math right in the return statement the way you can in a println (think about using parentheses).  You may find it easier to create local variables (as you would in main) inside toString for doing the math before the return statement.  Just make sure the return is the LAST statement in toString  (Do not add extra instance variables to the class to do this.)

☑ Also add a second  class with a main and there test out that all your variables and methods work correctly.

☑ Add to the ProgramStudent class an instance variable partner.  This variable should be of type ProgramStudent.  (Not String!  ProgramStudent!!!).  In your main, set up two students (make two instances) and make them each other’s partner.  Then, check in your main that you can do things like (you may have to change these to match your variable names…).  

student1.partner.introGrade = student1.introGrade; // student1’s partner’s intro grade
or

student1.partner.partner.partner.partner.acePracticalI(); // student1’s partner’s partner’s partner’s partner aces the Practical I