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...
Write a Java application that implements the following: Create an abstract class called GameTester. The GameTester...
Write a Java application that implements the following: Create an abstract class called GameTester. The GameTester class includes a name for the game tester and a boolean value representing the status (full-time, part-time). Include an abstract method to determine the salary, with full-time game testers getting a base salary of $3000 and part-time game testers getting $20 per hour. Create two subclasses called FullTimeGameTester, PartTimeGameTester. Create a console application that demonstrates how to create objects of both subclasses. Allow the...
In Java, please create a new Java application called "CheckString" (without the quotation marks) according to...
In Java, please create a new Java application called "CheckString" (without the quotation marks) according to the following guidelines. ** Each method below, including main, should handle (catch) any Exceptions that are thrown. ** ** If an Exception is thrown and caught, print the Exception's message to the command line. ** Write a complete Java method called checkWord that takes a String parameter called word, returns nothing, and is declared to throw an Exception of type Exception. In the method,...
Java Please comment code Create an Interactive JavaFX Application Create an application with the following controls:...
Java Please comment code Create an Interactive JavaFX Application Create an application with the following controls: A Label control with the following text displayed: "First Number:" A Label control with the following text displayed: "Second Number:" An empty TextField control beside the First Number label. An empty TextField control beside the Second Number label. Five buttons: Button 1 labeled + Button 2 labeled - Button 3 labeled * Button 4 labeled / Button 5 labeled = An empty Label control...
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...
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...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT