Ass 3 Prac 2
Ass 3 Prac 2
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 :
__________________________________________________
__________________________________________________
__________________________________________________
__________________________________________________