Employee Payroll System

This program models employee payroll system.

Problem Statement

Write a Java program to model Employee class with salary calculation.

Source Code

1 class Employee {
2 String name; double basic;
3 Employee(String n,double b){ name=n; basic=b; }
4 double calculateSalary(){ return basic+0.2*basic+0.1*basic; }
5 void show(){ System.out.println(name+"'s salary: "+calculateSalary()); }
6 }
7 public class EmployeePayroll {
8 public static void main(String[] args) {
9 System.out.println("Eduinq Employee Payroll");
10 Employee e=new Employee("Rahul",10000);
11 e.show();
12 }
13 }

Program Output

Eduinq Employee Payroll
Rahul's salary: 13000.0

Explanation

Employee class models payroll calculation. - Salary includes allowances. - Encapsulation ensures salary computed via method. Conclusion: Shows how to model employee payroll system.

Quick Links to Explore