Answer:
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
String name;
double hourlyRate;
int hours;
double grossPay = 0.0;
double netPaid = 0.0;
double taxes = 0.0;
Scanner input = new Scanner(System.in);
for (int i=1; i<=5; i++){
System.out.print("Enter the name of the employee #" + i + ": ");
name = input.nextLine();
System.out.print("Enter the hourly rate: ");
hourlyRate = input.nextDouble();
System.out.print("Enter the hours: ");
hours = input.nextInt();
input.nextLine();
if(hours > 40)
grossPay = (40 * hourlyRate) + ((hours - 40) * hourlyRate * 1.5);
else
grossPay = hours * hourlyRate;
taxes = grossPay * 0.2;
netPaid = grossPay - taxes;
System.out.println("\nName: " + name);
System.out.println("The number of hours worked: " + hours);
System.out.println("The weekly gross pay: " + grossPay);
System.out.println("Taxes: " + taxes);
System.out.println("Net Paid: " + netPaid + "\n");
}
}
}
Explanation:
*The code is in Java
Declare the variables
Create a for loop that iterates 5 times (for each employee)
Inside the loop:
Ask the user to enter the name, hourlyRate and hours
Check if hours is above 40. If it is, calculate the gross pay and overtime pay using the given instructions. Otherwise, do not add the overtime pay to the gross pay
Calculate the taxes using given information
Calculate the net paid by subtracting the taxes from grossPay
Print the name, hours, grossPay, taxes, and netPaid