EX NO: 3 PROGRAM TO GENERATE PAYSLIP USING INHERITANCE AIM To develop a java application to generate pay slip for different category of employees using the concept of inheritance. PROCEDURE 1. Create the class employee with name, Empid, address, mailid, mobileno as members. 2. Inherit the classes programmer, asstprofessor,associateprofessor and …
Question
EX NO: 3 PROGRAM TO GENERATE PAYSLIP USING INHERITANCE AIM To develop a java application to generate pay slip for different category of employees using the concept of inheritance. PROCEDURE 1. Create the class employee with name, Empid, address, mailid, mobileno as members. 2. Inherit the classes programmer, asstprofessor,associateprofessor and …
Solution
It seems like you're asking for a step-by-step guide on how to create a Java application to generate a payslip for different categories of employees using inheritance. Here's a simplified version of how you might do it:
- Create the base class
Employeewith attributes likename,empId,address,mailId, andmobileNo.
public class Employee {
String name;
int empId;
String address;
String mailId;
long mobileNo;
// constructor, getters and setters
}
- Create subclasses for each category of employee. In this case,
Programmer,AsstProfessor, andAssociateProfessor. These classes will inherit from theEmployeeclass.
public class Programmer extends Employee {
// Programmer-specific attributes and methods
}
public class AsstProfessor extends Employee {
// AsstProfessor-specific attributes and methods
}
public class AssociateProfessor extends Employee {
// AssociateProfessor-specific attributes and methods
}
- Each subclass should have a method to calculate the salary and generate a payslip. The method can be overridden in each subclass to account for different salary calculations.
public class Programmer extends Employee {
// ...
public void generatePayslip() {
// calculate salary and generate payslip for Programmer
}
}
// Do the same for AsstProfessor and AssociateProfessor
- Create instances of each subclass and call the
Similar Questions
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
21. Write a Java program that creates a class hierarchy for employees of a company. The base class should be Employee, with subclasses Manager, Developer, and Programmer. Each subclass should have properties such as name, address, salary, and job title. Implement methods for calculating bonuses, generating performance reports, and managing projects
e correct answerUsing which of the following, multiple inheritance in Java can be implemented?
[25 points] Write a Java class named Employee such that the class contains threeattributes empName, salary, and departmentName. You should be able to createobjects of this class by supplying values to any one, two, or all three of the attributes. Ifno value is supplied during the object creation, the attributes should be initialized withsome default values. You are expected to use 'this' keyword to achieve the result. Discussthe ways in which you can change or reset the attribute values of the objects created.Write appropriate mutator methods that store values in these fields and accessormethods that return the values in these fields. Once you have written the class, write aseparate program that creates three Employee objects to hold the following data:Employee Name Department Salary---------------------------------------------------------------------Susan Meyers Accounting 5000.00Mark Jones IT 8375.00Joy Rogers Manufacturing 6380.00---------------------------------------------------------------------The program should store this data in the three objects and then display the data for eachemployee on the screen
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
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.