Write a program that contains variables that holds the hourly rate and number
of hours worked for an employee who has the weekly salary for 250 an hour,
works 40 regular hours, and earns time and one-half (wage * 1.5) for overtime
hours worked. Display the gross pay, withholding tax, which is 15 percent of
the gross pay, and the net pay (gross pay – withholding).
import java.util.Scanner;
public class HourlyRate {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int hourlyRate = 0;
double grossPay = 0;
double payWithoutTax = 0;
System.out.println("Please provide number of hours worked for an employee on this week and press Enter:");
hourlyRate = scan.nextInt();
if (hourlyRate <= 40) {
grossPay = hourlyRate * 250;
} else if (hourlyRate > 40) {
grossPay = (((hourlyRate - 40) * 250) * 1.5) + (40 * 250);
}
System.out.println("Emploee gross pay is: " + grossPay);
payWithoutTax = grossPay - (grossPay * 15) / 100;
System.out.println("Emploee gross pay minus tax fee: " + payWithoutTax);
scan.close();
}
}
Comments
Leave a comment