0% found this document useful (0 votes)
10 views3 pages

Employee Payroll System Java

The document presents a Java program for an Employee Payroll System that demonstrates salary calculation, inheritance, and method overriding. It defines an Employee class and a Manager subclass, with methods to calculate and display annual salaries. The main method creates instances of Employee and Manager, displaying their details and salaries.

Uploaded by

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

Employee Payroll System Java

The document presents a Java program for an Employee Payroll System that demonstrates salary calculation, inheritance, and method overriding. It defines an Employee class and a Manager subclass, with methods to calculate and display annual salaries. The main method creates instances of Employee and Manager, displaying their details and salaries.

Uploaded by

123456bca987
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Program

/*
* Employee Payroll System
* Demonstrates salary calculation,
* inheritance, and method overriding.
*/

class Employee {
protected int id;
protected String name;
protected double salary;

public Employee(int id, String name, double salary) {


[Link] = id;
[Link] = name;
[Link] = salary;
}

public double calculateAnnualSalary() {


return salary * 12;
}

public void display() {


[Link]("ID: " + id);
[Link]("Name: " + name);
[Link]("Monthly Salary: " + salary);
[Link]("Annual Salary: " + calculateAnnualSalary());
}
}

class Manager extends Employee {


private double bonus;

public Manager(int id, String name, double salary, double bonus) {


super(id, name, salary);
[Link] = bonus;
}

@Override
public double calculateAnnualSalary() {
return (salary * 12) + bonus;
}
}

public class PayrollSystem {


public static void main(String[] args) {
Employee emp = new Employee(1, "Alice", 40000);
Manager mgr = new Manager(2, "Bob", 60000, 100000);

[Link]();
[Link]("---------------------");
[Link]();
}
}

/*
* Employee Payroll System
* Demonstrates salary calculation,
* inheritance, and method overriding.
*/

class Employee {
protected int id;
protected String name;
protected double salary;

public Employee(int id, String name, double salary) {


[Link] = id;
[Link] = name;
[Link] = salary;
}

public double calculateAnnualSalary() {


return salary * 12;
}

public void display() {


[Link]("ID: " + id);
[Link]("Name: " + name);
[Link]("Monthly Salary: " + salary);
[Link]("Annual Salary: " + calculateAnnualSalary());
}
}

class Manager extends Employee {


private double bonus;

public Manager(int id, String name, double salary, double bonus) {


super(id, name, salary);
[Link] = bonus;
}

@Override
public double calculateAnnualSalary() {
return (salary * 12) + bonus;
}
}

public class PayrollSystem {


public static void main(String[] args) {
Employee emp = new Employee(1, "Alice", 40000);
Manager mgr = new Manager(2, "Bob", 60000, 100000);

[Link]();
[Link]("---------------------");
[Link]();
}
}

/*
* Employee Payroll System
* Demonstrates salary calculation,
* inheritance, and method overriding.
*/

class Employee {
protected int id;
protected String name;
protected double salary;

public Employee(int id, String name, double salary) {


[Link] = id;
[Link] = name;
[Link] = salary;
}

public double calculateAnnualSalary() {


return salary * 12;
}

public void display() {


[Link]("ID: " + id);
[Link]("Name: " + name);
[Link]("Monthly Salary: " + salary);
[Link]("Annual Salary: " + calculateAnnualSalary());
}
}

class Manager extends Employee {


private double bonus;

public Manager(int id, String name, double salary, double bonus) {


super(id, name, salary);
[Link] = bonus;
}

@Override
public double calculateAnnualSalary() {
return (salary * 12) + bonus;
}
}

public class PayrollSystem {


public static void main(String[] args) {
Employee emp = new Employee(1, "Alice", 40000);
Manager mgr = new Manager(2, "Bob", 60000, 100000);

[Link]();
[Link]("---------------------");
[Link]();
}
}

You might also like