In: Computer Science
Write a Java application that inputs an unknown number of employees and determines and displays the gross pay for each employ. The company pays straight time for the first 40 hours worked by each employee (hours times rate), and straight time plus time-and-a-half for all hours worked in excess of 40 hours. Input the number of hours worked and hourly rate for each of the employees, then determine and display the employee’s gross pay. At the end of the program, print the total gross pay for all employees. Make sure you use the sentinel control Algorithm
import java.util.Scanner;
public class EmployeeSalaries {
public static void main(String[] args) {
Scanner sc = new
Scanner(System.in);
int ch = 1;
int hours;
double wage, rate, total = 0;
while (true) {
System.out.println("Enter number of worked hours (-1 to quit):
");
hours =
sc.nextInt();
if (hours ==
-1)
break;
System.out.println("Enter hourly rate: ");
rate =
sc.nextDouble();
if (hours <=
40) {
wage = hours * rate;
} else {
wage = 40 * rate;
wage = wage + (hours - 40) * rate * 1.5;
}
total +=
wage;
System.out.println("Wage is : $" + wage);
}
System.out.println("Total salaries:
$" + total);
}
}
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me