Java program to calculate the employee and employer provident fund

Input the basic salary of an employee, write a Java program to calculate the employee and employer provident fund.
Submitted by Nidhi, on February 23, 2022

Problem Solution:

In this program, we will read the basic salary of an employee from the user and calculate the employee, employer, and pension contribution of provident fund.

Program/Source Code:

The source code to calculate employee and employer provident fund is given below. the given program is compiled and executed successfully.

// Java program to calculate the Employee 
// and Employer Provident Fund

import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner X = new Scanner(System.in);

    float basicPay = 0;
    float employeeFund = 0;

    float employerFund = 0;
    float PensionFund = 0;

    System.out.printf("Enter basic pay: ");
    basicPay = X.nextFloat();

    employeeFund = (basicPay / 100) * 12.0F;
    employerFund = (basicPay / 100) * 3.67F;
    PensionFund = (basicPay / 100) * 8.33F;

    System.out.printf("Basic Pay: %f\n", basicPay);
    System.out.printf("Employee contribution: %f\n", employeeFund);
    System.out.printf("Employer Contribution: %f\n", employerFund);
    System.out.printf("Pension Contribution: %f\n", PensionFund);
  }
}

Output:

Enter basic pay: 15430
Basic Pay: 15430.000000
Employee contribution: 1851.600098
Employer Contribution: 566.281006
Pension Contribution: 1285.318970

Explanation:

In the above program, we imported the "java.util.Scanner" package to read input from the user. Here, we created a public class Main. It contains a static method main().

The main() method is an entry point for the program. And, we read the basic salary of an employee from the user using the nextFloat() method and calculated employee, employer, and pension contribution of Provident Fund. After that, we printed the result.

Java Basic Programs »



Related Programs




Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.