Check Company Work Efficiency in Java


35. In a company, worker efficiency is determined on the basis of the time required for a worker to complete a particular job. If the time taken by the worker is between 2 – 3 hours, then the worker is said to be highly efficient. If the time required by the worker is between 3 – 4 hours, then the worker is ordered to improve speed. If the time taken is between 4 – 5 hours, the worker is given training to improve his speed, and if the time taken by the worker is more than 5 hours, then the worker has to leave the company. If the time taken by the worker is input through the keyboard, find the efficiency of the worker


This Java program prompts the user to enter the time taken by a worker to complete a task and evaluates the worker's efficiency based on the time taken. The program uses a series of if statements to determine the worker's efficiency and prints a message to the console accordingly.

The program starts by importing the Scanner class from the java.util package, which is used to read user input from the console. It then defines the main method, which is the entry point for the program.

Inside the main method, the program prompts the user to enter the time taken by the worker to complete the task using the System.out.print statement and reads the input value using the Scanner.nextFloat method.

The program then uses a series of if statements to evaluate the worker's efficiency based on the time taken. If the time taken is between 2 and 3 hours, the program prints a message stating that the worker is highly efficient. If the time taken is between 3 and 4 hours, the program prints a message stating that the worker needs to improve speed. If the time taken is between 4 and 5 hours, the program prints a message stating that the worker needs training. If the time taken is greater than 5 hours, the program prints a message stating that the worker should leave the company.

Source Code

import java.util.Scanner;
class Work_Efficiency
{
	public static void main(String[] args)
	{
		Scanner input = new Scanner(System.in);
		System.out.print("Enter the Time Taken by Worker :");
		float hrs = input.nextFloat();
		if(hrs>=2 && hrs<=3) 
		{
			System.out.println("Worker is Highly Efficient");
		}
		else if(hrs>3 && hrs <=4) 
		{
			System.out.println("Worker Needs to Improve Speed");
		}
		else if(hrs>4 && hrs <=5) 
		{
			System.out.println("Give Training to Worker");
		}
		else
		{
			System.out.println("Worker is Leave the Company");
		}
	}
}

Output

Enter the Time Taken by Worker :4
Worker Needs to Improve Speed

Example Programs