C Programs Tutorials | IT Developer
IT Developer

Java Programs



Share with a Friend

Introduction to Java

Java Program: Salary Slip Generation with Allowances

Assumptions Used

Component

Percentage

HRA

20% of Basic Salary

DA

10% of Basic Salary

TA

5% of Basic Salary

PF

12% Deduction (Provident Fund)

Net Salary

Gross – Deductions

import java.util.Scanner;

 

public class SalarySlip {

    public static void main(String[] args) {

       

        Scanner sc = new Scanner(System.in);

 

        System.out.print("Enter Employee Name: ");

        String name = sc.nextLine();

 

        System.out.print("Enter Basic Salary: ");

        double basic = sc.nextDouble();

 

        // Allowances

        double hra = 0.20 * basic;   // 20%

        double da  = 0.10 * basic;   // 10%

        double ta  = 0.05 * basic;   // 5%

 

        // Deductions

        double pf  = 0.12 * basic;   // 12%

 

        double grossSalary = basic + hra + da + ta;

        double netSalary   = grossSalary - pf;

 

        // Salary Slip Output

        System.out.println("\n--------- SALARY SLIP ---------");

        System.out.println("Employee Name: " + name);

        System.out.println("Basic Salary : ₹" + basic);

        System.out.println("HRA (20%)    : ₹" + hra);

        System.out.println("DA  (10%)    : ₹" + da);

        System.out.println("TA  (5%)     : ₹" + ta);

        System.out.println("--------------------------------");

        System.out.println("Gross Salary : ₹" + grossSalary);

        System.out.println("PF Deduction : ₹" + pf);

        System.out.println("--------------------------------");

        System.out.println("Net Salary   : ₹" + netSalary);

       

        sc.close();

    }

}

Output

 
OUTPUT :
Enter Employee Name: John Dsouza
Enter Basic Salary: 30000

--------- SALARY SLIP ---------
Employee Name: John Dsouza
Basic Salary : ₹30000.0
HRA (20%)    : ₹6000.0
DA  (10%)    : ₹3000.0
TA  (5%)     : ₹1500.0
--------------------------------
Gross Salary : ₹40500.0
PF Deduction : ₹3600.0
--------------------------------
Net Salary   : ₹36900.0

Explanation

1. Input Section

  • Employee name (String)
  • Basic salary (double)

2. Allowance Calculation

  • HRA = 20% of basic
  • DA = 10% of basic
  • TA = 5% of basic

3. Deduction

  • PF = 12% of basic

4. Gross Salary

Gross = Basic + HRA + DA + TA

5. Net Salary

Net = Gross - PF

6. Output Salary Slip

The program prints a formatted salary slip with all components.