Question
You will need to complete the code in the three classes to finish the lab: The Student class is complete -- look at it to
You will need to complete the code in the three classes to finish the lab:
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 Lab8 class (following the comments there)
import java.util.*;
public class Lab8 { 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 } }
-------------------
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. } }
----------
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; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started