0% found this document useful (0 votes)
34 views4 pages

Ass 3 Prac 2

Uploaded by

nawazsayyad62it
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views4 pages

Ass 3 Prac 2

Uploaded by

nawazsayyad62it
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Problem Statement: Design and develop inheritance for a given case study,

identify objects and relationships and implement inheritance wherever


applicable. Employee class with Emp_name, Emp_id, Address, Mail_id,
and Mobile_no as members. Inherit the classes, Programmer, Team Lead,
Assistant Project Manager and Project Manager from employee class. Add
Basic Pay (BP) as the member of all the inherited classes with 97% of BP as
DA, 10 % of BP as HRA, 12% of BP as PF, 0.1% of BP for staff club fund.
Generate pay slips for the employees with their gross and net salary.

class Employee {
String empName;
int empId;
String address;
String mailId;
String mobileNo;
double basicPay;
public Employee(String empName, int empId, String address, String
mailId, String mobileNo) {
this.empName = empName;
this.empId = empId;
this.address = address;
this.mailId = mailId;
this.mobileNo = mobileNo;
}
public void calculateSalary() {
double da = 0.97 * basicPay; // Dearness Allowance (97% of Basic Pay)
double hra = 0.1 * basicPay; // House Rent Allowance (10% of Basic
Pay)
double pf = 0.12 * basicPay; // Provident Fund (12% of Basic Pay)
double staffClubFund = 0.001 * basicPay; // Staff Club Fund (0.1% of
Basic Pay)
double grossSalary = basicPay + da + hra; // Gross Salary
double netSalary = grossSalary - (pf + staffClubFund); // Net Salary
System.out.println("Pay Slip for: " + empName);
System.out.println("Employee ID: " + empId);
System.out.println("Gross Salary: " + grossSalary);
System.out.println("Net Salary: " + netSalary);
System.out.println("---------------------------------");
}
}
class Programmer extends Employee {
public Programmer(String empName, int empId, String address, String
mailId, String mobileNo) {
super(empName, empId, address, mailId, mobileNo);
this.basicPay = 50000;
}
}
class TeamLead extends Employee {
public TeamLead(String empName, int empId, String address, String
mailId, String mobileNo) {
super(empName, empId, address, mailId, mobileNo);
this.basicPay = 70000;
}
}
class AssistantProjectManager extends Employee {
public AssistantProjectManager(String empName, int empId, String
address, String mailId, String mobileNo) {
super(empName, empId, address, mailId, mobileNo);
this.basicPay = 90000;
}
}
class ProjectManager extends Employee {
public ProjectManager(String empName, int empId, String address,
String mailId, String mobileNo) {
super(empName, empId, address, mailId, mobileNo);
this.basicPay = 120000;
}
}
public class assignment2
{
public static void main(String[] args) {
Programmer programmer = new Programmer("Nawaz", 101, "New
Delhi", "[email protected]", "9876543210");
TeamLead teamLead = new TeamLead("Shreya", 102, "Mumbai",
"[email protected]", "9876543211");
AssistantProjectManager assistantPM = new
AssistantProjectManager("Sofiya", 103, "Bangalore",
"[email protected]", "9876543212");
ProjectManager projectManager = new ProjectManager("Prem", 104,
"Chennai", "[email protected]", "9876543213");

programmer.calculateSalary();
teamLead.calculateSalary();
assistantPM.calculateSalary();
projectManager.calculateSalary();
}
}
OUTPUT :

Conclusion :
__________________________________________________
__________________________________________________
__________________________________________________
__________________________________________________

You might also like