Java Program to calculate overtime pay of 10 employees. Overtime is paid at the rate of Rs. 12.00 per hour for every hour worked above 40 hours. Assume that employees do not work for fractional part of an hour.

import java.util.Scanner;

public class Program 
{   
    	public static void main( String[] args ) 
    	{

		Scanner reader = new Scanner(System.in);
		int i, time_worked, over_time, overtime_pay = 0;
		for (i = 1; i <= 10; i++)
		{
			System.out.print("\nEnter the time employee worked in hr ");
			time_worked = reader.nextInt();
			if (time_worked>40)
			{
				over_time = time_worked - 40;
				overtime_pay = overtime_pay + (12 * over_time);
			}
		}
		System.out.print("\nTotal Overtime Pay Of 10 Employees Is " + overtime_pay);
    	}
}

Output :
Enter the time employee worked in hr 42

Enter the time employee worked in hr 45

Enter the time employee worked in hr 42

Enter the time employee worked in hr 41

Enter the time employee worked in hr 50

Enter the time employee worked in hr 51

Enter the time employee worked in hr 52

Enter the time employee worked in hr 53

Enter the time employee worked in hr 54

Enter the time employee worked in hr 55

Total Overtime Pay Of 10 Employees Is 1020



Leave a comment