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
Data structures in java Implement the following classes: 1. class Course that includes three instance variables:...
Data structures in java Implement the following classes: 1. class Course that includes three instance variables: private String Name; // the course name private int ID; // the course ID private Course next; // the link Your class should have the following:  A constructor that initializes the two instance variables id and name.  Set and get methods for each instance variable. 2. class Department that includes three instance variables: private String deptName; private Course head, tail; Your class...
Code in Java SAMPLE PROGRAM OUTPUT Because there are several different things your program might do...
Code in Java SAMPLE PROGRAM OUTPUT Because there are several different things your program might do depending upon what the user enters, please refer to the examples below to use to test your program. Run your final program one time for each scenario to make sure that you get the expected output. Be sure to format the output of your program so that it follows what is included in the examples. Remember, in all examples bold items are entered by...
In c++ create a class to maintain a GradeBook. The class should allow information on up...
In c++ create a class to maintain a GradeBook. The class should allow information on up to 3 students to be stored. The information for each student should be encapsulated in a Student class and should include the student's last name and up to 5 grades for the student. Note that less than 5 grades may sometimes be stored. Your GradeBook class should at least support operations to add a student record to the end of the book (i.e., the...
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...
In java please: You have been given the job of creating a new order processing system...
In java please: You have been given the job of creating a new order processing system for the Yummy Fruit CompanyTM. The system reads pricing information for the various delicious varieties of fruit stocked by YFC, and then processes invoices from customers, determining the total amount for each invoice based on the type and quantity of fruit for each line item in the invoice. The program input starts with the pricing information. Each fruit price (single quantity) is specified on...
For this assignment, you need to submit a Python program that gathers the following employee information...
For this assignment, you need to submit a Python program that gathers the following employee information according to the rules provided: Employee ID (this is required, and must be a number that is 7 or less digits long) Employee Name (this is required, and must be comprised of primarily upper and lower case letters. Spaces, the ' and - character are all allowed as well. Employee Email Address (this is required, and must be comprised of primarily of alphanumeric characters....
Objective: Write a Java program that will use a JComboBox from which the user will select...
Objective: Write a Java program that will use a JComboBox from which the user will select to convert a temperature from either Celsius to Fahrenheit, or Fahrenheit to Celsius. The user will enter a temperature in a text field from which the conversion calculation will be made. The converted temperature will be displayed in an uneditable text field with an appropriate label. Specifications Structure your file name and class name on the following pattern: The first three letters of your...
In Java please 10.9 Lab 6 In BlueJ, create a project called Lab6 Create a class...
In Java please 10.9 Lab 6 In BlueJ, create a project called Lab6 Create a class called LineSegment –Note: test changes as you go Copy the code for LineSegment given below into the class. Take a few minutes to understand what the class does. Besides the mutators and accessors, it has a method called print, that prints the end points of the line segment in the form: (x, y) to (x, y) You will have to write two methods in...
I need this before the end of the day please :) In Java 10.13 Lab 10...
I need this before the end of the day please :) In Java 10.13 Lab 10 Lab 10 This program reads times of runners in a race from a file and puts them into an array. It then displays how many people ran the race, it lists all of the times, and if finds the average time and the fastest time. In BlueJ create a project called Lab10 Create a class called Main Delete what is in the class you...