Derive an Administrator class from SalariedEmployee in stored in the files secti
ID: 3842463 • Letter: D
Question
Derive an Administrator class from SalariedEmployee in stored in the files section on canvas.You'll need to download the files employee.cpp, employee.h, salariedemployee.cpp, andsalariedemployee.h. You can find these in Canvas under Files HWHW8code
It is allowed (actually, it is recommended) to change the protection qualifier private toprotected in the base class.
Supply the following additional data and function members.
A variable of type string named title to contain the administrator's title. Examples:
Director, Vice President
A variable of type string named responsibility to hold the name of the area of
responsibility of the administrator. Example: Finance, Accounting, and Personnel.
A variable of type string named supervisor to hold the name of the administrator's
immediate supervisor.
A protected member variable of type double to hold the administrator's annual
salary.
A member function, setSupervisor, to change the name of the supervisor.
A member function to allow keyboard entry of the administrator's data.
A member function, print, that does screen display of administrator's data.
An overloaded member function printCheck() to print the administrator's data on the
check.
Write a main function to test all the member functions and functionality of your derived class
Explanation / Answer
import java.util.Scanner; class Employee { int age; String name, address, gender; Scanner get = new Scanner(System.in); Employee() { System.out.println("Enter Name of the Employee:"); name = get.nextLine(); System.out.println("Enter Gender of the Employee:"); gender = get.nextLine(); System.out.println("Enter Address of the Employee:"); address = get.nextLine(); System.out.println("Enter Age:"); age = get.nextInt(); } void display() { System.out.println("Employee Name: "+name); System.out.println("Age: "+age); System.out.println("Gender: "+gender); System.out.println("Address: "+address); } } class fullTimeEmployees extends Employee { float salary; int des; fullTimeEmployee() { System.out.println("Enter Designation:"); des = get.nextInt(); System.out.println("Enter Salary:"); salary = get.nextFloat(); } void display() { System.out.println("=============================="+" "+"Full Time Employee Details"+" "+"=============================="+" "); super.display(); System.out.println("Salary: "+salary); System.out.println("Designation: "+des); } } class partTimeEmployees extends Employee { int workinghrs, rate; partTimeEmployees() { System.out.println("Enter Number of Working Hours:"); workinghrs = get.nextInt(); } void calculatepay() { rate = 8 * workinghrs; } void display() { System.out.println("=============================="+" "+"Part Time Employee Details"+" "+"=============================="+" "); super.display(); System.out.println("Number of Working Hours: "+workinghrs); System.out.println("Salary for "+workinghrs+" working hours is: $"+rate); } } class Employees { public static void main(String args[]) { System.out.println("================================"+" "+"Enter Full Time Employee Details"+" "+"================================"+" "); fullTimeEmployees ob1 = new fullTimeEmployees(); partTimeEmployees ob = new partTimeEmployees(); System.out.println("================================"+" "+"Enter Part Time Employee Details"+" "+"================================"+" "); ob1.display(); ob.calculatepay(); ob.display(); } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.