PROJECT ON Employee Payroll(java)

📘 Salary Terms Explained

Sl. No. Term Full Form Definition Formula / Calculation Example (₹)
1 Basic Pay The fixed part of an employee’s salary (before adding allowances or deductions). Basic Pay = 20,000
2 HRA House Rent Allowance Allowance given to cover house rent expenses. HRA = 20% of Basic Pay HRA = 20% of 20,000 = 4,000
3 DA Dearness Allowance Allowance to manage inflation (rising prices). DA = 10% of Basic Pay DA = 10% of 20,000 = 2,000
4 Gross Salary The total salary before deductions. Gross = Basic + HRA + DA 20,000 + 4,000 + 2,000 = 26,000
5 Deductions The amount subtracted (PF, tax, loans, etc.). Deduction = 1,500
6 Net Salary The final salary taken home after deductions. Net = Gross − Deductions 26,000 − 1,500 = 24,500


CODE

import java.util.Scanner; public class EMP { public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.println("ENTER 1:Junior"); System.out.println("ENTER 2:Senior"); int choice = s.nextInt(); System.out.println("Enter EMP NAME: "); String name1 = s.next(); System.out.print("Enter Employee ID: "); int empId1 = s.nextInt(); System.out.print("Enter Basic Pay: "); double bs1 = s.nextDouble(); // Declare all variables outside double hra = 0, da = 0, ef = 0, grosssalary = 0, netsalary = 0; switch(choice) { case 1: hra = (20.0/100) * bs1; da = (10.0/100) * bs1; ef = (12.0/100) * bs1; System.out.println("\n--- Employee Payroll (Junior) ---"); break; case 2: hra = (25.0/100) * bs1; da = (15.0/100) * bs1; ef = (12.0/100) * bs1; System.out.println("\n--- Employee Payroll (Senior) ---"); break; default: System.out.println("Invalid choice!"); s.close(); return; // exit early if invalid choice } // Common output grosssalary = bs1 + hra + da; netsalary = grosssalary - ef; System.out.println("Employee ID : " + empId1); System.out.println("Employee Name : " + name1); System.out.println("Basic Pay : " + bs1); System.out.println("HRA : " + hra); System.out.println("DA : " + da); System.out.println("Gross Salary : " + grosssalary); System.out.println("Deductions : " + ef); System.out.println("Net Salary : " + netsalary); } }



OUTPUT:

Sample Input (user types)

Enter Employee ID: 101

Enter Employee Name: Ramesh

Enter Basic Pay: 20000

Enter Deductions: 1500

 

💻 Program Output

--- Employee Payroll ---

Employee ID   : 101

Employee Name : Ramesh

Basic Pay     : 20000.0

HRA (20%)     : 4000.0

DA (10%)      : 2000.0

Gross Salary  : 26000.0

Deductions    : 1500.0

Net Salary    : 24500.0

Comments

Popular posts from this blog

class 8 computer chapter 5

CLASS 8 COMPUTER

Class 5 computer chapter 4