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

Code is in JAVA Part I Write a class CourseListException that extends Exception

ID: 652087 • Letter: C

Question

Code is in JAVA

Part I

Write a class CourseListException that extends Exception with the following constructors:

A default constructor that gives the error message "Too many courses."

A constructor that takes a string and uses this for the error message

Part II

Write a class Student with the following attributes:

Two instance variables (with corresponding getters and setters):

name - a String for the name of the student

courses - an array of Strings with length 5, holding the names of the courses the Student is taking.

A default constructor that initializes name to be "NoName".

A constructor that takes a String to set the name of the student

Two methods:

assignCourses (no input parameters or return values) - This method should ask a user to input courses from the console window until the user enters an empty line, which indicates the end of the array. If the user enters more than 5 courses, throw a CourseListException

writeStudent (no input parameters or return values) - writes the name of the student and the names of the student's courses to the console window

Part III

Write a class PartTimeStudent, a subclass of Student, for students who can take at most 2 courses. The class should include the following:

A default constructor that invokes the superclass constructor

A constructor that takes a String to set the name of the Student

An overridden assignCourses that throws a CourseListException when a user tries to assign more than 2 courses to a PartTimeStudent.

Part IV

Write a class TestStudent that does the following:

1)Creates a student with the name Alice

2)Assigns some courses to Alice

3)Writes the information about Alice to the console window

4)Creates a PartTimeStudent with the name Bob

5)Assigns courses to Bob

6)Writes the information about Bob to the console

Explanation / Answer

package cis35a.project4.JoshBiso; import java.util.Scanner; import java.util.ArrayList; import java.util.Date; class Student { private Scanner in = new Scanner(System.in); private String studentName; private long studentID; private String address; private String phone; private boolean fulltimeStatus; private float gpa; private ArrayList courseList; public Student(){ } public Student(String studentName, long studentID){ this.studentName=studentName; this.studentID=studentID; } public Student(String studentName, long studentID, String address, String phone, boolean fulltimeStatus, float gpa){ this.studentName = studentName; this.studentID= studentID; this.address=address; this.phone=phone; this.fulltimeStatus= fulltimeStatus; this.gpa=gpa; } public void setStudentName(String studentName){ this.studentName=studentName; } public void setStudentID(long studentID){ this.studentID=studentID; } public void setAddress(String address){ this.address=address; } public void setPhone(String phone){ this.phone=phone;} public boolean setfulltimeStatus(boolean fulltimeStatus){ if(courseList.size()>=3){ this.fulltimeStatus=fulltimeStatus; System.out.print("Fulltime Student"); return true; } else { this.fulltimeStatus=fulltimeStatus; System.out.print("Parttime Student"); return false;} } public void setGpa(float gpa){ for(int i=1;i
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