Question

In: Computer Science

This is in Java 1. Create an application called registrar that has the following classes: a....

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.

Solutions

Expert Solution

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


Related Solutions

Part 1 – Classes and objects Create a new Java project called usernamePart1 in NetBeans. In...
Part 1 – Classes and objects Create a new Java project called usernamePart1 in NetBeans. In my case the project would be called rghanbarPart1. Select the option to create a main method. Create a new class called Vehicle. In the Vehicle class write the code for: • Instance variables that store the vehicle’s make, model, colour, and fuel type • A default constructor, and a second constructor that initialises all the instance variables • Accessor (getters) and mutator (setters) methods...
Create a Java application called ValidatePassword to validate a user’s password. Write a program that asks...
Create a Java application called ValidatePassword to validate a user’s password. Write a program that asks for a password, then asks again to confirm it. If the passwords don’t match or the rules are not fulfilled, prompt again. Your program should include a method that checks whether a password is valid. From that method, call a different method to validate the uppercase, lowercase, and digit requirements for a valid password. Your program should contain at least four methods in addition...
JAVA A simple Class in a file called Account.java is given below. Create two Derived Classes...
JAVA A simple Class in a file called Account.java is given below. Create two Derived Classes Savings and Checking within their respective .java files. (modify display() as needed ) 1. Add New private String name (customer name) for both, add a New int taxID for Savings only. 2. Add equals() METHOD TO CHECK any 2 accounts Demonstrate with AccountDemo.java in which you do the following: 3. Create 1 Savings Account and 3 Checking Accounts, where 2 checkings are the same....
Write a console application called PlayingCards that has 4 classes: PlayingCards, Deck, Cards, Card. This application...
Write a console application called PlayingCards that has 4 classes: PlayingCards, Deck, Cards, Card. This application will be able to create a deck of cards, shuffle it, sort it and print it. Use the following class diagrams to code your application. Use the following code for the PlayingCards class public class PlayingCards{ public static void main(String[] args){                 System.out.println("Playings Cards");                 Deck deck = new Deck();                 deck.create();                 System.out.println("Sorted cards");                 deck.sort();                 deck.showCards();                 System.out.println("Shuffled cards");                 deck.shuffle();...
Create a java Swing GUI application that presents the user with a “fortune”. Create a java...
Create a java Swing GUI application that presents the user with a “fortune”. Create a java Swing GUI application in a new Netbeans project called FortuneTeller. Your project will have a FortuneTellerFrame.java class (which inherits from JFrame) and a java main class: FortuneTellerViewer.java. Your application should have and use the following components: Top panel: A JLabel with text “Fortune Teller” (or something similar!) and an ImageIcon. Find an appropriate non-commercial Fortune Teller image for your ImageIcon. (The JLabel has a...
Create a java program that will do the following: Create a method called getInt.Allow the user...
Create a java program that will do the following: Create a method called getInt.Allow the user to enter up to 20 student names,and for each student 3 quiz scores (in the range 0-100). Once input is done, display each student’s name, their three quiz scores, and their quiz score average, one student per line. The output table does not need to line up perfectly in columns.Use dialog boxes for all input and output.Use the method to input the three scores.Parameter...
I need a Java application with a GUI that includes the following requirements: Three classes minimum...
I need a Java application with a GUI that includes the following requirements: Three classes minimum At least one class must use inheritance At least one class must be abstract Utilization of “get set” method. (get; set; =  is related to how variables are passed between different classes. The get method is used to obtain or retrieve a particular variable value from a class. A set value is used to store the variables. The whole point of the get and set...
Write an application and perform the following:(NO USER INPUT) -Create at least three classes such as:...
Write an application and perform the following:(NO USER INPUT) -Create at least three classes such as: 1. listnode- for data and link, constructors 2. Singlelinkedlist-for method definition 3. linkedlist-for objects -Insert a node at tail/end in a linked list. -and display all the nodes in the list. -Delete a node at a position in the list Note: Add these methods in the same application which we have done in the class. this is what we've done in the class: class...
JAVA LANGUAGE Required Tasks: In Eclipse, create a Java Project as CS-176L-Assign5. Create 3 Java Classes...
JAVA LANGUAGE Required Tasks: In Eclipse, create a Java Project as CS-176L-Assign5. Create 3 Java Classes each in its own file Student.java, StudentList.java, and Assign5Test.java. Copy your code from Assignment 4 into the Student.java and StudentList.java Classes. Assign5Test.java should contain the main method. Modify StudentList.java to use an ArrayList instead of an array. You can find the basics of ArrayList here: https://www.w3schools.com/java/java_arraylist.asp In StudentList.java, create two new public methods: The addStudent method should have one parameter of type Student and...
Create a moderately complex java program that utilises 2 or more classes. Within these classes: -...
Create a moderately complex java program that utilises 2 or more classes. Within these classes: - have one that defines an exception - have that exception throw(n) in one method and handled in another -has the program continue even if the user inputs incorrect data -be creative/unique in some way
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT