Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are responsible for creating two separate java files. 1) The first class is

ID: 2247488 • Letter: Y

Question

You are responsible for creating two separate java files.

1) The first class is a Student class (Student.java) that has the following properties and behaviors:

a) Members

i) Firstname (String _fname)

ii) Lastname (String _lname)

iii) An array of Courses (Course [] _cArry) iv) An int for the number of courses (int _numCourses)

b) Methods

i) Constructor

(1) Student(firstname, lastname, numCourses)

(a) The first 2 parameters are assigned to the corresponding members that belong to the object (You learned how to do this in Chap 9).

b) The final parameter is used to initialize _cArry (You learned how to initialize arrays in Chapter 7).

ii) createCourse(String courseName, int creditHours, char letterGrade)

(1) This method creates a new Course and adds it to _cArry

iii) computeGPA()

(1) This method computes the GPA for all courses in _cArry using the credit hours and grade information.

iv) toString()

(1) insert the following line of code inside this method return "Student " + _fname + " " + _lname + " has a " + Course.computeGPA(_cArry) + “ GPA”; Example output: Student Jane Doe has a 3.4 GPA

2) The second class is a Main class (Main.java) that creates 3 students (3 separate Student objects) with the following information (1) Name: Jane Doe (Note: number of courses is 5)

(a) List of Courses

1. Course Name: Math, Credit Hours: 4, Letter Grade: ‘A’

2. Course Name: English, Credit Hours: 3, Letter Grade: ‘A’

3. Course Name: CS, Credit Hours: 4, Letter Grade: ‘A’

4. Course Name: Chemistry, Credit Hours: 3, Letter Grade: ‘B;

5. Course Name: Health, Credit Hours: 2, Letter Grade: ‘B’

(2) Name: John Smith (Note: number of courses is 5) (a) List of Courses

1. Course Name: Math, Credit Hours: 4, Letter Grade: ‘B’

2. Course Name: English, Credit Hours: 3, Letter Grade: ‘B’

3. Course Name: CS, Credit Hours: 4, Letter Grade: ‘C’

4. Course Name: Chemistry, Credit Hours: 3, Letter Grade: ‘C;

5. Course Name: Health, Credit Hours: 2, Letter Grade: ‘B’

(3) Name: David Hill (Note: number of courses is 3) (a) List of Courses

1. Course Name: Math, Credit Hours: 4, Letter Grade: ‘C’

2. Course Name: English, Credit Hours: 3, Letter Grade: ‘A’

3. Course Name: Health, Credit Hours: 2, Letter Grade: ‘A’

Explanation / Answer

Hi,
1. Student.java


public class Student {

   private String _fname;
   private String _lname;
   private Course [] _cArry;
   private int _numCourses;
   public Student(String firstname, String lastname, int numCourses){
       super();
       this._fname = firstname;
       this._lname = lastname;
       this._numCourses = numCourses;
       _cArry = new Course[numCourses];
   }
  
   public void createCourse(String courseName, int creditHours, char letterGrade) {
       Course course = new Course(courseName, creditHours, letterGrade);
  
       for( int i =0; i< _cArry.length; i++) {
            if(_cArry[i] == null) {
               _cArry[i] = course;
                break;
            }
       }
   }
  
  
   @Override
   public String toString() {
      
       return "Student " + _fname + " " + _lname + " has a " + Course.computeGPA(_cArry) + " GPA";
   }
}



2. Course.java


public class Course {

   private String courseName;
   private int creditHours;
   private char letterGrade;
  
   public Course(String courseName, int creditHours, char letterGrade) {
       this.courseName = courseName;
       this.creditHours = creditHours;
       this.letterGrade = letterGrade;
   }

   public String getCourseName()
   {
       return courseName;
   }

   public void setCourseName(String courseName)
   {
       this.courseName = courseName;
   }

   public int getCreditHours()
   {
       return creditHours;
   }

   public void setCreditHours(int creditHours)
   {
       this.creditHours = creditHours;
   }

   public char getLetterGrade()
   {
       return letterGrade;
   }

   public void setLetterGrade(char letterGrade)
   {
       this.letterGrade = letterGrade;
   }

   public static String computeGPA(Course[] _cArry) {
       String GPA = "";
      
       for( int i =0; i< _cArry.length; i++) {
            Course c = _cArry[i];
          
       }
       return GPA;
   }
  
}


3. Main.java


public class Main {

   public static void main(String[] args) {
      
       Student jane = new Student("Jane", "Doe", 5);
       jane.createCourse("Math", 4, 'A');
       jane.createCourse("English", 3, 'A');
       jane.createCourse("CS", 4, 'A');
       jane.createCourse("Chemistry", 3, 'B');
       jane.createCourse("Health", 2, 'B');
      
       Student john = new Student("John", "Smith", 5);
       john.createCourse("Math", 4, 'B');
       john.createCourse("English", 3, 'B');
       john.createCourse("CS", 4, 'C');
       john.createCourse("Chemistry", 3, 'C');
       john.createCourse("Health", 2, 'B');
      
       Student david = new Student("David", "Hill", 3);
       david.createCourse("Math", 4, 'C');
       david.createCourse("English", 3, 'A');
       david.createCourse("Health", 2, 'A');
      
       System.out.println(jane);
       System.out.println(john);
       System.out.println(david);

   }
}


I need all detail about document because Course class have some functionality.
what is base of computeGPA using credit hours and grade?
can you give detail about this i will update to you.

Let me konw

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote