Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

People: This is the object at the top of the object hierarchy. Constructor of the People class take first_name, last_name, and the phone number as

People: This is the object at the top of the object hierarchy. Constructor of the People class take first_name, last_name, and the phone number as parameters. It sets the payRate and the monthlyPay to zero. payRate will represent the academic year salary for each type of employee in the employee class. The toString method will return the first_name , last_name, and the phone number. calculatePay() method will set the monthlyPay to zero. The getName() method returns the first name and the last name.

Employee: The Employee class has an additional data member, payScale, that will be common for both faculty and Staff. payScale is either 9 month or 12 month. So, the input for this is either 9 or 12. The constructor of the Employee class takes the first_name, last_name, phone number, payRate, and the payScale as parameters.

Faculty: The faculty class has additional data members: department and classesTeach. The constructor of the Faculty class takes the first_name, last_name, phone number, payRate, payScale, and the department as parameters. The addClass method takes the name of the class and add to the classesTeach arraylist. The toString method will returns the first_name, last_name, classes teach, and the monthly pay. Finally the calculatePay method will calculate the monthly pay using the following equations monthlyPay = payRate/payScale + 500*number of classes teach

Staff: The Staff class has an additional data member title that represents the job title. The constructor of the Staff class takes the first_name, last_name, phone number, payRate, payScale, and the title as parameters. The toString method will returns the first_name, last_name, title, and the monthly pay Finally the calculatePay method will calculate the monthly pay using the following equations monthlyPay = payRate/payScale

Student: The Student class has additional data members gpa and the major. The constructor of the Student will takes the first_name, last_name, phone number and the major as parameters. It sets the gpa to zero. The setGpa method will take the new gpa as a parameter and change the object gpa value. The changeMajor method take the major as a parameter and change the major of the Student object. The toString method will return the first_name, last_name, phone number, major, and the gpa

//university

import java.util.*;

public class University {

public static void main(String args[])

{

String univ_Name, location;

ArrayList people = new ArrayList();

char choice = 'A';

String line;

Scanner scan = new Scanner(System.in);

// read the name and the location of the university here

do{

System.out.print("What action would you like to perform? ");

printMenu();

line = scan.nextLine();

if (line.length() == 1)

{

choice = line.charAt(0);

choice = Character.toUpperCase(choice);

switch(choice)

{

case 'A':

// add a Student here

/* read the first name, last name, phone number, major as parameters and then call the

* constructor of the Student class to create the instance

* then read the gpa, call setGpa method of the student to set the gpa

* finally add the student instance to the people list

*/

break;

case 'B':

// add a Staff here

/* read the first name, last name, phone number, payRate, payScale, and title and then call the

* constructor of the Staff class to create the instance

* finally add the Staff instance to the people list

*/

break;

case 'C':

// add a Faculty here

/* read the first name, last name, phone number, payRate, payScale, and department and then call the

* constructor of the Faculty class to create the instance

* read list of courses the instructor read and call the addClass method

* of the faculty to add classes

* finally add the Faculty instance to the people list

*/

break;

case 'D':

// display university info

/* university name, location, number of students, number of faculty and number of

*staff

*/

break;

case 'E':

// display people info

/* display the fist name and the last name of each person at school

*

*/

break;

case 'F':

// display Student info

/* display fist name, last name, and the major of each student

* java has a construct called instanceof. That construct can determine

* the object instance type

* example:

* String str = new String("hello");

* if(str instanceof String) will be evaluated to true

*/

break;

case 'G':

// display Employee info

/* display fist name, last name, pay rate, and monthly pay of each employee

*

*/

break;

case 'Q':

// quit the program

break;

case '?':

// display the menu again

break;

default:

System.out.println("default");

}

} else

{

System.out.print("Unknown action ");

}

}while(choice != 'Q');

}

public static void printMenu()

{

System.out.print("Choice\t\tAction " +

"------\t\t------ " +

"A\t\tAdd a Student " +

"B\t\tAdd a Staff " +

"C\t\tAdd a Faculty "+

"D\t\tDisplay University Info " +

"E\t\tDisplay University People Info " +

"F\t\tDisplay University Student Info " +

"G\t\tDisplay University Employee Info " +

"Q\t\tQuit " +

"?\t\tDisplay Menu Again ");

}

}

image text in transcribed

University People name: String location: String eople People + static void main(O #first-name: String #last-name: String n l#phoneNumber:String #pay Rate: double #monthly,Pay-double +People(String, String, String) +calculatePay0 +String getName0 +String toStrin Student Employee -major String #payScale: int +Employee(String, String, String, int, double) pa double +Student(String, String, String, String) void setGpa(double) void changeMajor(String) +String toString Faculty Staff -department String -classes Teach:Strin +Faculty(String, String, String, double, int, String) +oid addClass(String) void calculatePay0) +String toString( -title String +Staff(String, String, String, double, int, String) +String toString0 +void calculatePay University People name: String location: String eople People + static void main(O #first-name: String #last-name: String n l#phoneNumber:String #pay Rate: double #monthly,Pay-double +People(String, String, String) +calculatePay0 +String getName0 +String toStrin Student Employee -major String #payScale: int +Employee(String, String, String, int, double) pa double +Student(String, String, String, String) void setGpa(double) void changeMajor(String) +String toString Faculty Staff -department String -classes Teach:Strin +Faculty(String, String, String, double, int, String) +oid addClass(String) void calculatePay0) +String toString( -title String +Staff(String, String, String, double, int, String) +String toString0 +void calculatePay

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

(1 point) Calculate 3 sin x cos x dx.

Answered: 1 week ago

Question

Find the derivative of y= cos cos (x + 2x)

Answered: 1 week ago

Question

The nature and importance of the global marketplace.

Answered: 1 week ago