In: Computer Science
This is in Java
1. Create an application called registrar that has the following classes:
a. A student class that minimally stores the following data fields for a student:
Name
Student id number
Number of credits
Total grade points earned
And this class should also be provides the following methods:
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
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)
b. An instructor class that minimally stores the following data
fields for an instructor:
Name
Faculty id number
Department
The following methods should be provided:
A constructor that initializes the name and id fields
Methods to set and retrieve the instructor’s department.
c. A course class that minimally stores the following data for a
course:
Name of the course
Course registration code
Maximum number of 50 students
Instructor
Number of students
Students registered in the course (array)
The following methods should also be provided
A constructor that initialize 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 should be based on an ID number.
A method to add a student to the course.
A method to remove a student from the course.
import java.util.Scanner;
class Student
{
String s_name;
int credit_no;
int stud_id;
int grade_points;
Student()
{
System.out.println("Enter Student
name:: ");
Scanner SC=new
Scanner(System.in);
s_name=SC.nextLine();
System.out.println("Enter Student
id:: ");
stud_id=SC.nextInt;
}
String ret_name()
{
return name;
}
int ret_id()
{
return stud_id;
}
void set_ret_credits()
{
char choice;
int temp;
Scanner SC=new
Scanner(System.in);
System.out.println("Do you wish to
set value of credit?? (y/n)");
choice=SC.nextChar();
if(choice=="y" ||
choice=='Y')
{
System.out.println("Enter credit value:: ")
temp=SC.nextInt();
credit_no+=temp;
}
System.out.println("Number of
Credits" + credit_no);
}
void set_ret_grade()
{
char choice;
int temp;
Scanner SC=new
Scanner(System.in);
System.out.println("Do you wish to
set value of grade points?? (y/n)");
choice=SC.nextChar();
if(choice=="y" ||
choice=='Y')
{
System.out.println("Enter credit value:: ")
temp=SC.nextInt();
grade_points+=temp;
}
System.out.println("Number of Grade
points" + grade_points);
}
float gpa()
{
return(grade_points/credit_no);
}
}
class Instructor
{
String i_name;
int faculty_id;
String dept;
Instructor()
{
System.out.println("Enter
Instructor name:: ");
Scanner SC=new
Scanner(System.in);
i_name=SC.nextLine();
System.out.println("Enter faculty
id:: ");
faculty_id=SC.nextInt;
}
void set_ret_dept()
{
char choice;
Scanner SC=new
Scanner(System.in);
System.out.println("Do you wish to
set department? (y/n)");
choice=SC.nextChar();
if(choice=="y" ||
choice=='Y')
{
System.out.println("Enter Department:: ")
dept=SC.nextLine();
}
System.out.println("Department
name=" + dept);
}
}
class Course
{
String c_name;
int reg_code;
int max_stud;
Instructor i;
int stud_no;
int reg_stud[50];
Course()
{
Scanner SC=new
Scanner(System.in);
System.out.println("Enter number of students registered:: ");
max_stud=SC.nextInt();
System.out.println("Enter course name:: ");
c_name=SC.nextLine();
System.out.println("Enter registration code:: ");
reg_code=SC.nextLine;
}
void set_ret_instructor()
{
char choice;
Scanner SC=new
Scanner(System.in);
i=new Instructor();
System.out.println("Instructor
name=" + i_name);
System.out.println("Instructor
faculty id:: "+ faculty_id );
}
boolean search()
{
int search_key;
System.out.println("Enter
registration number of student to search:: ");
search_key=SC.nextInt();
for(int
i=0;i<max_stud;i++)
if(search_key==reg_stud[i])
return true;
return false;
}
void add_stud()
{
int stud_new;
System.out.println("Enter
registartion number of new student:: ");
stud_new=SC.nextInt();
reg_stud[max_stud]=stud_new;
max_stud++;
}
void remove_stud()
{
int rem_stud;
System.out.println("Enter
registration number of student:: ");
rem_stud=SC.nextInt();
for(int
i=0;i<max_stud;i++)
if(search_key==reg_stud[i])
reg_stud[i]=0;
}
}
Write the testing code appropriately to your needs.
The Outline of your given problem will be as above.. make the needful changes according to your requirements..
Please give feedback. Thank you