Create an application called Registrar that has the following classes using JAVA
ID: 3562167 • Letter: C
Question
Create an application called Registrar that has the following classes using JAVA:
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
-department
The following methods should also be provided:
-A constructor that initializes the name and id fields.
-Methods to set and retrieve the instructor's department.
A course class that minimally stores the following data for a course:
-name if the course
-course registration code
-maximum number of 35 students
-instructor
-number of students
-students registered in the course (an arrary)
The following methods should also be provided:
-A constructor that initializes the name, registration code, and maximum number of students
-Methods to set and retrieve the instructor
-A method to search for a student in the course; the search shold be based on an ID number.
-A methid to add a student to the course. If the course is full, then an exception with an appropraite 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 the course. If the student is not found then an axception with an approprate message should be raised (use the same exception class mentioned above)
-A methid tha will allow course objects to be output to a file using object serialization
-A method that will allow course objects to be read in from a file created with object serialzation.
Finally, 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 name and id fields and also provide a toString method that returns a string of the form name, id.
Explanation / Answer
Student Class
import java.util.*;
public class Student {
String name=new String();
String student_id=new String();
int credits;
double grade_earn;
public Student(){
}
public Student(String std_name,String id)
{
name=std_name;
student_id=id;
System.out.println("Name:"+this.name);
System.out.println("Student Id:"+this.student_id);
}
@Override
public boolean equals(Object other){
if (other == this) return true;
return false;
}
public String getName()
{
return this.name;
}
public String getId()
{
return this.student_id;
}
public void setCredit(int credits)
{
this.credits=credits;
}
public int getCredit()
{
return this.credits;
}
public void setGrade(double grade)
{
this.grade_earn=grade;
}
public double getGrade()
{
return this.grade_earn;
}
public double getGPA()
{
return this.grade_earn/this.credits;
}
public void show()
{
System.out.println("Name:"+this.name);
System.out.println("Student Id:"+this.student_id);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.