Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I was needing help with this computer science project about classes and objects as stated. Thanks in advance _________________________________ Here are the codes for the

I was needing help with this computer science project about classes and objects as stated. Thanks in advance

_________________________________

Here are the codes for the three classes: Student, Course, and Proj8:

Student Code:

public class Student {

private String name;

private String major;

private double gpa;

public Student(String n, String m, double g) {

name = n;

major = m;

gpa = g;

}

public void print() {

System.out.println(name + " " + major + " " + gpa);

}

public String getName() {

return name;

}

public double getGPA() {

return gpa;

}

public String getMajor() {

return major;

}

}

Course:

public class Course {

private Student[] roster;

private int size;

public Course(int capacity) {

roster = new Student[capacity];

size = 0;

}

public void addStudent(String name, String major, double gpa) {

//YOU DO THIS

//Create a Student object representing the parameter information

//Add the Student object to position "size" in the roster array

//Update size

//If the array is full, do nothing (don't add the student)

//(Alternatively, you can resize the array if you want)

}

public void printStudentsWithMajor(String m) {

//YOU DO THIS

//Call the "print" method for all students on the roster

//whose major matches "m"

}

public void printHonorRoll() {

//YOU DO THIS

//Call the "print" method for all students on the roster

//whose gpa is at least 3.5.

}

}

Proj8:

import java.util.*;

public class Proj8 {

public static void main(String[] args) {

//YOU DO THIS

//Create a Course object that can hold 10 students

//Loop to ask the user for information for 10 students

//for each one, get the name, major, and gpa

//add each student to the Course object

//Ask the user to enter a major

//Call a method in Course to print all students with that major

//Print all student's on the honor roll (by calling a method in Course

}

}

If you are using Eclipse, start a new project and add three new classes to that project: Student, Course, and Proj8. Copy and paste the code from the downloaded files and paste them into those three classes.

If you are using the command-prompt, you can store those three downloaded Java files in whatever location you store your work, and then start editing them.

You will need to complete the code in the three classes to finish the project:

- The Student class is complete -- look at it to see what it does, but don't change any of the code

- Complete the methods in the Course class (following the comments there)

- Complete the main method in the Proj8 class (following the comments there)

______________________________

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Demonstrate how to use the Gaps Model for diagnosing and

Answered: 1 week ago