Simple employee salary calculator

 In this example consider that every employee is getting $37.50 per hour and the standard hours per week is 40 hours/week. If any employee works more than 40 hours per week then he/she should be earning $2.50 additional per extra hour worked.

import java.util.Scanner;

public class SalaryCalculator {

    public static void main(String[] args) {

        System.out.print("Enter number of hours worked: ");
        Scanner in = new Scanner(;
        double totalHoursWorked = in.nextInt();
        double standardWage = 37.50;
        int standardHours = 40;
        double totalWage;
        double overtimeBonus = 2.50;

        if (totalHoursWorked > 40)
            totalWage = (standardWage * totalHoursWorked)
                        + (totalHoursWorked - standardHours) * overtimeBonus;
        else if (totalHoursWorked < 40)
            totalWage = standardWage * totalHoursWorked;
            totalWage = standardWage * standardHours;

        System.out.println("Your total salary of the week is: " + totalWage);


Enter number of hours worked: 30
Your total salary of the week is: 1125.0

1 comment:

  1. It is indeed a very useful program (calculator) for calculating the wages of the employees. However, in real life scenarios the company changes policies very often and the factors of calculating the salary of the staff could be very complex.

    Payroll Providers Guelph