Question

Project 2 statement Please write this in JAVA. Please read this entire statement carefully before you...

Project 2 statement

Please write this in JAVA.


Please read this entire statement carefully before you start doing anything…

This project involves implementing a simple university personnel management program. The program contains two different kinds of objects: students and faculty. For each object, the program stores relevant information such as university ID, name, etc. Different information is stored depending on the type of the object. For example, a student has a GPA, while a faculty has a title and department (professor, mathematics).

For each of any class data member, your program must include the getters and the setters, and each class must include at least two constructors. The goal of this Project is to demonstrate the use of inheritance, abstract classes, abstract methods and method overriding.

Student class has:

  • Full name
  • ID
  • Gpa
  • Number of credit hours currently taken

Faculty class has:

  • Full name
  • ID
  • Department (mathematics, engineering, arts and science)
  • Rank (professor, adjunct)

Students in this college pay $236.45 per credit hour in addition to a $52 administrative fee. Your code should generate a tuition invoice ( a method within the class Student). Note that students get a 25% off total payment if their gpa is greater or equal to 3.85.

Both classes Faculty and Student inherit from the abstract class Person. The abstract class Person has what’s common to both Faculty and Student, and it is left to you (the programmer) to come out with an abstract method that you implement in your classes Faculty and Student.

Test your code with one array of size 100 of type Person (Or you may use an ArrayList object). The sample run below should give you a clear idea about how your code should run. The user’s entry is marked in bold so you can tell what your code should display to the screen and what the user enters.

Please note well that:

  1. Your code should run exactly as shown on the sample run below (However, the TA will not deduct points because you skipped two lines instead of three or your tuition invoice has 56 hyphens instead of 63 ).
  2. When asked to enter the faulty’s department, matheMatics and MathematiCs are considered to be the same, and your program should display Mathematics if faculty information is to be displayed to the screen. However, if the user enters Mathematics department, then this is an invalid entry. Consider theses departments only: Mathematics, Physics and Engineering. As for the rank of a faculty, consider theses ranks only: Professor and Adjunct.
  3. The university ID has no required form so you may choose to enter anything to be the ID.

Welcome to my Personal Management Program

Choose one of the options:

  1. Add a new Faculty member
  2. Add a new Student
  3. Print tuition invoice for a student
  4. Print information of a faculty
  5. Exit Program

Enter your selection: 2

Enter the student’s info:

Name of Student: Julia Alvarez

ID: ju1254

Gpa: 3.26

Credit hours: 7

   Thanks!

Choose one of the options:

  1. Add a new Faculty member
  2. Add a new Student
  3. Print tuition invoice for a student
  4. Print information of a faculty
  5. Exit Program

Enter your selection: 2

Enter the student’s info:

Name of Student: Matt Jones

ID: ma0258

Gpa: 2.78

Credit hours: 0

Thanks!

  1. Add a new Faculty member
  2. Add a new Student
  3. Print tuition invoice for a student
  4. Print information of a faculty
  5. Exit Program

Enter your selection: a

Invalid entry- please try again

  1. Add a new Faculty member
  2. Add a new Student
  3. Print tuition invoice for a student
  4. Print information of a faculty
  5. Exit Program

Enter your selection: 1

Enter the faculty’s info:

Name of the faculty: John Miller

ID: jo7894

Rank: Instructor

Sorry entered rank (Instructor) is invalid

Rank: Professor

Department: Engineering

   Thanks!

  1. Add a new Faculty member
  2. Add a new Student
  3. Print tuition invoice for a student
  4. Print information of a faculty
  5. Exit Program

Enter your selection: 3

Enter the student’s id: ju1254

Here is the tuition invoice for Julia Alvarez :

---------------------------------------------------------------------------

Julia Alvarez ju1254

Credit Hours:7 ($236.45/credit hour)

Fees: $52

Total payment: $1,707.15 ($0 discount applied)

---------------------------------------------------------------------------

  1. Add a new Faculty member
  2. Add a new Student
  3. Print tuition invoice for a student
  4. Print information of a faculty
  5. Exit Program

Enter your selection: 3

Enter the student’s id: eri856

Sorry-student not found!

  1. Add a new Faculty member
  2. Add a new Student
  3. Print tuition invoice for a student
  4. Print information of a faculty
  5. Exit Program

Enter your selection: 4

Enter the faculty’s id: jo8578

Sorry jo8578 doesn’t exist

  1. Add a new Faculty member
  2. Add a new Student
  3. Print tuition invoice for a student
  4. Print information of a faculty
  5. Exit Program

Enter your selection: 4

Enter the faculty’s id: JO7894

Faculty found:

---------------------------------------------------------------------------

John Miller

Engineering Department, Professor

---------------------------------------------------------------------------

  1. Add a new Faculty member
  2. Add a new Student
  3. Print tuition invoice for a student
  4. Print information of a faculty
  5. Exit Program

Enter your selection: 5

Goodbye!

Homework Answers

Answer #1

// Person.java

public abstract class Person
{
   private String ID;
   private String name;
  
   // default constructor
   public Person()
   {
       ID = "";
       name = "";
   }
  
   // parameterized constructor
   public Person(String ID, String name)
   {
       this.ID = ID;
       this.name= name;
   }
  
   // abstract method to display the details
   public abstract void display();
  
   // getters
   public String getID()
   {
       return ID;
   }
  
   public String getName()
   {
       return name;
   }
  
   // setters
   public void setID(String ID)
   {
       this.ID = ID;
   }
  
   public void setName(String name)
   {
       this.name = name;
   }
}
//end of Person.java

// Faculty.java
public class Faculty extends Person
{
   private String department;
   private String rank;
  
   // default constructor
   public Faculty()
   {
       super();
       department = "";
       rank = "";
   }
  
   // parameterized constructor
   public Faculty(String ID, String name, String department, String rank)
   {
       super(ID,name);
       this.department = department;
       this.rank = rank;
   }
  
   // setters
   public void setDepartment(String department)
   {
       this.department = department;
   }
  
   public void setRank(String rank)
   {
       this.rank = rank;
   }
  
   // getters
   public String getDepartment()
   {
       return department;
   }
  
   public String getRank()
   {
       return rank;
   }
  
   // display the details of Faculty
   public void display()
   {
       System.out.println("---------------------------------------------------------------------------");
       System.out.println(getName());
       System.out.println(department.substring(0,1).toUpperCase()+department.substring(1).toLowerCase()+ " Department, "
                   +rank.substring(0,1).toUpperCase()+rank.substring(1).toLowerCase());
       System.out.println("---------------------------------------------------------------------------");
   }
}
//end of Faculty.java

// Student.java

public class Student extends Person
{
   private double gpa;
   private int credit_hours;
  
   // default constructor
   public Student()
   {
       super();
       gpa = 0;
       credit_hours = 0;
   }
  
   // parameterized constructor
   public Student(String ID, String name, double gpa, int credit_hours)
   {
       super(ID, name);
       this.gpa = gpa;
       this.credit_hours = credit_hours;
   }
  
   // setters
   public void setGPA(double gpa)
   {
       this.gpa = gpa;
   }
  
   public void setCreditHours(int credit_hours)
   {
       this.credit_hours = credit_hours;
   }
  
   // getters
   public double getGPA()
   {
       return gpa;
   }
  
   public int getCreditHours()
   {
       return credit_hours;
   }
  
   // display the details of Student
   public void display()
   {
       System.out.println("---------------------------------------------------------------------------");
       System.out.println(getName()+" "+getID());
       System.out.println("Credit Hours: "+credit_hours +" ($236.45/credit hour)");
       System.out.println("Fees: $52");
       double discount = getDiscount();
       if(discount == 0)
           System.out.printf("Total payment: $%,.2f ($0 discount applied)\n",getTotalInvoice());
       else
           System.out.printf("Total payment: $%,.2f ($%,.2f discount applied)\n",getTotalInvoice()-discount,discount);
       System.out.println("---------------------------------------------------------------------------");
   }
  
   // helper method to calculate and return total invoice
   private double getTotalInvoice()
   {
       return((credit_hours*236.45)+52);
   }
  
   // helper method to return discount if any
   private double getDiscount()
   {
       if(gpa >= 3.85)
           return 0.25*getTotalInvoice();
       else
           return 0;
   }
}
//end of Student.java

// PersonTester.java

import java.util.ArrayList;
import java.util.Scanner;

public class PersonTester {

   public static void main(String[] args) {

       // create an array list to store Person objects
       ArrayList<Person> personList = new ArrayList<Person>();
       System.out.println("Welcome to my Personal Management Program");
       Scanner keyboard = new Scanner(System.in);
       String ID, name, dept, rank;
       int hours;
       double gpa;
       String choice;
      
       System.out.println("Choose one of the options: ");
       // loop that continues until the user exits
       do
       {
           System.out.println("Add a new Faculty member");
           System.out.println("Add a new Student");
           System.out.println("Print tuition invoice for a student");
           System.out.println("Print information of a faculty");
           System.out.println("Exit Program");
          
           // input of choice
           System.out.print("Enter your selection: ");
           choice = keyboard.nextLine();
          
           if(choice.equals("1")) // insert faculty
           {
               System.out.println("Enter the faculty’s info:");
               System.out.print("Name of the faculty: ");
               name = keyboard.nextLine();
               System.out.print("ID: ");
               ID = keyboard.nextLine();
               System.out.print("Rank: ");
               rank = keyboard.nextLine();
               while(!(rank.equalsIgnoreCase("Professor") || rank.equalsIgnoreCase("Adjunct")))
               {
                   System.out.println("Sorry entered rank ("+rank+") is invalid");
                   System.out.print("Rank: ");
                   rank = keyboard.nextLine();
               }
              
               System.out.print("Department: ");
               dept = keyboard.nextLine();
               while(!(dept.equalsIgnoreCase("Mathematics") || dept.equalsIgnoreCase("Physics") || dept.equalsIgnoreCase("Engineering")))
               {
                   System.out.println("Sorry entered department ("+dept+") is invalid");
                   System.out.print("Department: ");
                   dept = keyboard.nextLine();
               }
              
               personList.add(new Faculty(ID,name,dept,rank));
               System.out.println("Thanks!");
           }
           else if(choice.equals("2")) // insert student
           {
               System.out.println("Enter the student’s info:");
               System.out.print("Name of Student: ");
               name = keyboard.nextLine();
               System.out.print("ID: ");
               ID = keyboard.nextLine();
               System.out.print("Gpa: ");
               gpa = keyboard.nextDouble();
               while(gpa < 0)
               {
                   System.out.println("Sorry entered GPA ("+gpa+") is invalid");
                   System.out.print("Gpa: ");
                   gpa = keyboard.nextDouble();
               }
               System.out.print("Credit hours: ");
               hours = keyboard.nextInt();
               while(hours < 0)
               {
                   System.out.println("Sorry entered Credit hours ("+hours+") is invalid");
                   System.out.print("Credit hours: ");
                   hours = keyboard.nextInt();
               }
              
               keyboard.nextLine();
              
               personList.add(new Student(ID,name,gpa,hours));
               System.out.println("Thanks!");
           }
           else if(choice.equals("3")) // display student info
           {
               System.out.print("Enter the student's id: ");
               ID = keyboard.nextLine();
               boolean flag = false;
               for(Person person: personList)
               {
                   if((person instanceof Student) && (person.getID().equalsIgnoreCase(ID)))
                   {
                       flag = true;
                       System.out.println("Here is the tuition invoice for "+person.getName()+": ");
                       person.display();
                       break;
                   }
                  
               }
              
               if(!flag)
                   System.out.println("Sorry-student not found!");
           }
           else if(choice.equalsIgnoreCase("4")) // display faculty info
           {
               System.out.print("Enter the faculty's id: ");
               ID = keyboard.nextLine();
               boolean flag = false;
               for(Person person: personList)
               {
                   if((person instanceof Faculty) && (person.getID().equalsIgnoreCase(ID)))
                   {
                       flag = true;
                       System.out.println("Faculty found");
                       person.display();
                       break;
                   }
                  
               }
              

               if(!flag)
                   System.out.println("Sorry "+ID+" doesn't exist");
           }
           else if(!choice.equalsIgnoreCase("5")) // invalid choice
           {
               System.out.println("Invalid entry- please try again");
           }
       }while(!choice.equalsIgnoreCase("5"));
      
       System.out.println("Goodbye!");
   }

}
//end of PersonTester.java

Output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Problem Statement: Write a Java program “HW6_lastname.java” that prints a program title and a menu with...
Problem Statement: Write a Java program “HW6_lastname.java” that prints a program title and a menu with four items. The user should then be prompted to make a selection from the menu and based on their selection the program will perform the selected procedure. The title and menu should be as the following: Student name: <your name should be printed> CIS 232 Introduction to Programming Programming Project 6 Due Date: October 23, 2020 Instructor: Dr. Lomako ******************************** 1.     Compute Angles                               *...
This program is in C++: Write a program to allow the user to: 1. Create two...
This program is in C++: Write a program to allow the user to: 1. Create two classes. Employee and Departments. The Department class will have: DepartmentID, Departmentname, DepartmentHeadName. The Employee class will have employeeID, emploeename, employeesalary, employeeage, employeeDepartmentID. Both of the above classes should have appropriate constructors, accessor methods. 2. Create two arrays . One for Employee with the size 5 and another one for Department with the size 3. Your program should display a menu for the user to...
Please answer in JAVA IDS 401 Assignment 4 Deadline In order to receive full credit, this...
Please answer in JAVA IDS 401 Assignment 4 Deadline In order to receive full credit, this assignment must be submitted by the deadline on Blackboard. Submitting your assignment early is recommended, in case problems arise with the submission process. Late submissions will be accepted (but penalized 10pts for each day late) up to one week after the submission deadline. After that, assignments will not be accepted. Assignment The object of this assignment is to construct a mini-banking system that helps...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts,...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts, it will present a welcome screen. You will ask the user for their first name and what class they are using the program for (remember that this is a string that has spaces in it), then you will print the following message: NAME, welcome to your Magic Number program. I hope it helps you with your CSCI 1410 class! Note that "NAME" and "CSCI...
Create an uml Sequence Diagrams for the following scenario A student at Grambling must register for...
Create an uml Sequence Diagrams for the following scenario A student at Grambling must register for class and pay for the class each term. Show all the steps done in the process starting with getting your pin to paying your fees.   Go to GSU’S website: www.gram.edu 2. Click on current student and then Banner Web 3. Click on Enter Secure Area 4. To Login: a. Enter User ID: Student ID No. e.g., GXXXXXXXX b. Enter PIN#: Date of Birth (mmddyy)...
please write the code in java so it can run on jGRASP import java.util.Scanner; 2 import...
please write the code in java so it can run on jGRASP import java.util.Scanner; 2 import java.io.*; //This imports input and output (io) classes that we use 3 //to read and write to files. The * is the wildcard that will 4 //make all of the io classes available if I need them 5 //It saves me from having to import each io class separately. 6 /** 7 This program reads numbers from a file, calculates the 8 mean (average)...
You are approached by a 3rd year health sciences student who is trying to recruit you...
You are approached by a 3rd year health sciences student who is trying to recruit you to participate in a study of student mental health. You are told that it involves an online survey, and covers topics like your current mental health, whether or not you access campus resources for mental health care, past experiences that may have been involved in the determination of your mental health experiences, and how your mental health relates to your academic outcomes during first...
a. Define the class bankAccount to store a bank customer’s account number and balance. Suppose that...
a. Define the class bankAccount to store a bank customer’s account number and balance. Suppose that account number is of type int, and balance is of type double. Your class should, at least, provide the following operations: set the account number, retrieve the account number, retrieve the balance, deposit and withdraw money, and print account information. Add appropriate constructors. b. Every bank offers a checking account. Derive the class checkingAccount from the class bankAccount (designed in part (a)). This class...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world applications. In your summary, provide an example of a software project that you can create using STL templates and provide a brief explanation of the STL templates you will use to create this project. After that you will implement the software project you described . Your application must be a unique project and must incorporate the use of an STL container and/or iterator and...