Develop a Java application that will determine the gross pay for each of
three employees. The company pays straight time for the first 40 hours
worked by each employee and time and a half for all hours worked in
excess of 40 hours. You are given a list of the employees of the company,
the number of hours each employee worked last week and the hourly rate
of each employee. Your program should input this information for each
employee and should determine and display the employee’s gross pay.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (true) {
System.out.println("Name(empty - Exit):");
String name = in.nextLine();
if(name.length()==0){
break;
}
System.out.println("Hours");
int hours = Integer.parseInt(in.nextLine());
System.out.println("Rate:");
double rate = Double.parseDouble(in.nextLine());
System.out.println(name + " Gross: " + (hours <= 40 ? rate * hours : (rate * 40) + (rate * (hours - 40) * 1.5)));
}
}
}
Comments
Leave a comment