rendered paste bodypublic class Pay
{
public static void main (String args[])
{
int hours, rate;
DecimalFormat decFor = new DecimalFormat("0.00");
Scanner scan = new Scanner(System.in);
System.out.print("Enter the number of hours worked: ");
hours = scan.nextInt();
if (hours < 0 && hours >60 ){
do {
System.out.print("Invalid entry - enter a number of hours worked between 0 and 60: ");
hours = scan.nextInt();
} while (hours < 0 || hours > 60);
}
System.out.print("Enter the rate of pay: ");
rate = scan.nextInt();
if (rate < 0 || rate > 1500){
do {
System.out.print("Invalid entry - enter a rate of pay between 0 and 1500: ");
rate = scan.nextInt();
} while (rate < 0 || rate > 1500);
}
double basepay, overtimepay, total, tax, netpay ;
if (hours >= 0 && hours <=40 ){
basepay = hours * rate ;
overtimepay = 0 ;
}
if (hours > 40 && hours <=60) {
basepay = 40 * rate ;
overtimepay = (hours -40) * (rate * 1.5);
}
total = overtimepay + basepay;
System.out.print("Base pay is $" + basepay);
System.out.print("Overtime pay is $" + overtimepay);
System.out.print("Total pay is $" + total);
if ( total <= 500){
tax = 0;
}
if (total > 500 && total <= 2000) {
tax = total * 0.2;
}
if (total > 2000) {
tax = total *0.3;
}
netpay = total - tax;
System.out.print("Tax deducted is $" + tax);
System.out.print("Net pay is $" + netpay);
}}