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

Create an application called Registrar that has the following classes: A Student

ID: 3527791 • Letter: C

Question

Create an application called Registrar that has the following classes: A Student class that minimally stores the following data fields for student: -name -student id -number of credits -total grade points earned The following methods should also be provided: -A constructor that initializes the name and id fields -a method that returns the student name field -A method that returns the student ID field --A method that determines if two student objects are equal if their student id numbers are the same (override equals from the class object) -Methods to set and retrieve the total number of credits -Methods to set and retrieve the total number of grade points earned -A method that returns the GPA (grade points divided by credits) An Instructor class that minimally stores the following data fields for an instructor: -name -faculty id number -department The following methods should also be provided: -A constructor that initializes the name and id fields -Methods to set and retrieve the instructors department A Course class that minimally stores the following data for course: -name of course -course registration code -maximum number of 5 students -instructor -number of students -students registered in the course ( an array) The following methods should also be provided: -A constructor that initializes the name, registration code, and maximum number of students -Methods to set instructor -A method to search for a student in a course; the search should be based on an ID number -A method to add a student to the course. If the course is full, then an exception with an appropriate message should be raised (try creating your own exception class for this). Also, be sure that the student is not already registered in the course. The list of students should be in the order that they registered. -A method to remove a student from a course. If the student is not found, then and exception with an appropriate message should be raised(use the same exception class mentioned above). You will note that Student and Instructor classes described above have some commonality. Create a Person class that captures this commonality and uses it as a base class for Student and Instructor. This class should be responsible for the name and ID fields and also provide a toString method that returns a string of the form name, id. This will be the inherited toString method for Student and Instructor classes. -Write a main program that can serve as a test class that tests all of the methods created and demos that they work -Write a second main program that provides a menu to allow the user to: Create a course, prompting the user for all the course information Add students to the course Check to see if a student is registered in the course and remove a student from the course

Explanation / Answer

The question u asked has three classes to be implemented, please follow the code I've written for you..

import java.io.*;

public class Student extends Person

{

String sname;

int sid;

int no_of_credits, tot_grade_pts;

Student(String sname,int sid)

{

this.sname=sname;

this.sid=sid;

}

String get_name()

{

return sname;

}

int get_sid()

{

return sid;

}

boolean two_equal(int sid)

{

if((this.sid)==sid)

return true;

else

return false;

}

void set_credits(int credits)

{

no_of_credits=credits;

}

int get_credits()

{

return no_of_credits;

}

void set_tot_gpts(int gpts)

{

tot_grade_pts=gpts;

}

int get_tgpts()

{

return tot_grade_pts;

}

float get_GPA()

{

return ((tot_grade_pts)/(no_of_credits));

}

}

public class Instructor extends Person

{

String iname;

int fid;

String dept;

Instructor(iname,fid)

{

this.iname=iname;

this.fid=fid;

}

void set_dept(String dept)

{

this.dept=dept;

}

String get_dept()

{

return dept;

}

}

public class Course

{

String cname,instructor_name;

int creg_code, max_students,no_of_students;

ArrayList<int> reg_students=new ArrayList<int>();

Course(String cname,int creg_code,int max_students)

{

this.cnamecname;

this.creg_code=creg_code;

this.max_students=max_students;

}

void set_instructor(String instructor_name)

{

this.instructor_name=instructor_name;

}

boolean search_student(int sid)

{

if(reg_students.contains(sid))

return true;

else

return false;

}

public class MyException extends Exception

{

}

void add_student(int sid)

{

try{

if((reg_students.size)==max_students)

{

throw new MyException();

}

else

reg_students.add(sid);

}

catch(Exception e)

{

System.out.println("Course has maximum students");

}

}

void rem_student(sid)

{

try{

if(reg_student.contains(sid))

reg_students.remove(new Integer(sid));

else

throw new MyException();

}catch(Exception e)

{System.out.println("NO STUDENT FOUND WITH THE GIVEN id");}

}

}

public class Person

{

String sname,iname;

int fid,sid;

}

public class Registrar

{

public static void main(String args[])

{

Course c1=new Course(default_course,123,10);

int ch,regcode,max_stu,sid;

String cname,sname;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

do{

System.out.println("Enter your choice:");

System.out.println("1. create a course, 2. add a student, 3. remove a student, 4. exit");

ch=(Integer)br.readLine();

switch(ch)

{

case 1:System.out.println("Enter course name");

cname=br.readLine();

System.out.println("Eter registration code");

regcode=(Integer)br.readLine();

System.out.println("Enter max students");

max_stu=(Integer)br.readLine();

Course c=new Course(cname,regcode,max_stu);

break;

case 2:System.out.println("Enter student name");

sname=br.readLine();

System.out.println("Enter id");

sid=(Integer)br.readLine();

c1.add_student(sid);

break;

case 3: System.out.println("Enter student id");

sid=(Integer)br.readLine();

c1.remove_student(sid);

break;

}

}while(ch!=4);

}//main close

}// class close

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