Question: Java Part - D [2 25=10 Marks ] Answer All the following questions: Q31. Write a program in java for the following scenario and write
Part - D [2 25=10 Marks ] Answer All the following questions: Q31. Write a program in java for the following scenario and write a Driver closs to test your construction: 1. Create a class NctStaff with the following members: Instance variables: staffld // staff id String type name /iname of the staff String type Method Members: i) double calculateSalary( ) // abstract method which calculate and return salary. ii) int workLoad(int teachinghrs, int nonteachinghrs ) //use to calculate and retum workload. workload= teachinghrs + nonteachinghrs; 2. Create a subclass CompanyStaff inherit from NetStaff class with the following members: Instance variables: String cname ame of the company. double basic// basic salary. double hra// house allowence. Constructor: to set the values of the instance variables and also call the super class constructor. Method Members: i) Define the method calculateSalary( )// to calculate the salary using the formula given below: salary=hra+basic. ii) void display(): to display staff id , name -company name and salary. 3. Create a subclass MinistryStaff inherit from NctStaff class with the following members: Instance variables: char grade// salary grade. Constructor: to set the values of the instance variables and also call the super class constructor. Method Members: i) Define the method calculateSalary( )/ to calculate the salary using the formula given below: ii) void display( ): to display staff id , name , grade and salary. In the main method do the following:- 1) Create objects of the subrlasses using following input: CompanyStaff("e608001", "Mohammed","Bahwan",2000,2.5) ElectricalEngine("3000cc",2500,600) 2) Calculate used Fuel for the PerrolEngine. 3) Calculate used Fuel for the ElectricalEngine. 4) Find type of cylinder for the PetrolEngine. 5) Find type of cylinder for the ElectricalEnghe. 6) Display all the details of PetrolEngine and ElectricalEngine, duye I of 10
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
