Knowee
Questions
Features
Study Tools

Define a class Employee. Display the personal salary details of three employeesusing single inheritance

Question

Define a class Employee. Display the personal salary details of three employeesusing single inheritance

🧐 Not the exact question you are looking for?Go ask a question

Solution

To define a class Employee, follow these steps:

  1. Start by creating a new class called Employee.
  2. Inside the Employee class, define the necessary attributes for an employee's personal salary details. These attributes could include variables such as employee_name, employee_id, and salary.
  3. Create a constructor method within the Employee class to initialize the attributes of each employee. This method should take parameters for the employee's name, ID, and salary, and assign them to the corresponding attributes.
  4. Define a method within the Employee class to display the personal salary details of an employee. This method could be named display_salary_details and should print out the employee's name, ID, and salary.
  5. Now, create three instances of the Employee class, each representing a different employee. Use the constructor method to initialize the attributes of each employee with their respective details.
  6. Finally, call the display_salary_details method on each employee instance to display their personal salary details.

By following these steps, you can define the Employee class and display the personal salary details of three employees using single inheritance.

This problem has been solved

Similar Questions

Write a program to demonstrate multiple inheritance. Consider two base classes worker(int code, char name, float salary), HR who calculates the different allowances like (float DA, HRA). You have another class manger with calculates (float TA(is 10% of salary), gross salary) where the properties of worker and HR is used in this class. Write a test application class to create an array of 10 workers and display their details with gross salary.

Create a class employee with protected members:Name,age,degree,genderCreate a member function to read the details.  Create a derived class department by inheriting the employee class privately.Declare the protected members: department_name, designation.Create a member function to read the details of the department.Create a member function to display the details of employee class and department class.Create a derived class salary by inheriting the employee class privately with protected members: basic payCreate default constructor to read basic pay.Define a member function to calculate the gross pay. Gross_pay=basic_pay+DA+HRADA=30% of basic payHRA =12% of basic payCreate a member function to display the details of employee class and the grosspay.

Create the class Employee with name, Empid, address, mailid, mobileno as data members.Inherit the classes programmer,Asstprofessor, Associateprofessor and Professor from employee class.Add Basic Pay (BP) as the member of all the inherited classes..Calculate DA as 97% of BP, HRA as 8% of BP, PF as 10% of BP, Staff club fund as 0.1% of BP.Calculate gross salary and net salary.Generate payslip for programmer categories of employees.Calculate DA as 97% of BP, HRA as 10% of BP, PF as 12% of BP, Staff club fund as 0.1% of BP.Calculate gross salary and net salary.Generate payslip for Asstprofessor categories of employees.Calculate DA as 97% of BP, HRA as 7% of BP, PF as 13% of BP, Staff club fund as 0.1% of BP.Calculate gross salary and net salary.Generate payslip for Associateprofessor categories of employees, Create the objects for the inherited classes and invoke the necessary methods to display the Payslip.Calculate DA as 97% of BP, HRA as 4% of BP, PF as 13% of BP, Staff club fund as 0.2% of BP.Calculate gross salary and net salary.Generate payslip for Professor categories of employees,Choose the options 1.PROGRAMMER 2.ASSISTANT PROFESSOR 3.ASSOCIATE PROFESSOR 4.PROFESSORinput2Arun [email protected], Anna Nagar, Chennai-6550029876543210 20000outputArun [email protected] 12, Anna Nagar, Chennai65987654321020000.019400.02000.02400.02000.041400.037000.0

Define a class “employee” having employee id, name and salary use accept and to-string method to display and create n employee’s data and find the total salary of all employees and find the name of the employee who is having maximum salary.

Create a Java  base class called Employee. Use this class to store two double-type values that could be used to compute the salary of employees. Also,the base class should have a static variable ‘totalemp’  to keep track of the total number of employees created. Derive two specific classes called part_time and full_time from the base employee. Add a member function called as get_basic() to get the basic pay and another member called display_salary() to compute and display the salary of the employees. Using these three classes, design a program that will accept the basic pay of part_time and full_time employees interactively. Remember the two values given as input will be treated as the basic pay of the employees and the following information is used for calculating the salaries of both the part-time as well as full-time employees. Print invalid if the basic_salary of part-time employee and basic_salary of full-time employee are not met the ”Boundary Condition”Part time                                         Full timeHRA = 20% of basic pay                    HRA = 30% of basic payDA = 72% of basic pay                      DA = 80% of basic paySalary = Basic + HRA + DA              Salary = Basic + HRA + DABoundary Condition:0 < basic_salary of part-time employee <= 10000000 < basic_salary of full-time employee <= 1000000Input Format:First line to enter the basic_salary of part-time employee and basic_salary of full-time employeeOutput Format:Total salary of part-time employee and total salary of full-time employee.Total number of employees processed Sample Testcase Input-1:50007000000Sample Testcase Output-1:8900.0invalid1 Sample Testcase Input-2:30000600000Sample Testcase Output-2:42720.0110400.02 Sample Testcase Input-3:0900000Sample Testcase Output-3:invalid216000.01

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.