can any help me with this while loop it should follow a maximum of 40 regular hours, a maximum of 20 overtime hours, and a maximum of $10.00 for the hourly pay rate. evertime i put my while loop in the code and run it , it doesnt do anything plz help me

while loop for the regular hour max 40
while loop for man 20 overtime
while loop for max $10

final double FED_TAX_RATE = .20;
final double STATE_TAX_RATE = .05;
final double SOC_SEC_TAX_RATE = .10;

int regularHours = 40;
int overtimeHours;
double hourlyRate;
double grossPay;
double netPay;
double fedTax;
double stateTax;
double ssTax;

Scanner keyboard = new Scanner (System.in);

NumberFormat currencyFormat = NumberFormat.getCurrencyInstance();
NumberFormat percentFormat = NumberFormat.getPercentInstance();

System.out.print ("Enter the number of regular hours worked: ");
regularHours = keyboard.nextInt();


System.out.print ("Enter the number of overtime hours worked: ");
overtimeHours = keyboard.nextInt();

System.out.print ("Enter the hourly rate: ");
hourlyRate = keyboard.nextDouble();

grossPay = (regularHours * hourlyRate) + (overtimeHours * (hourlyRate * 1.5));
fedTax = grossPay * FED_TAX_RATE;
stateTax = grossPay * STATE_TAX_RATE;
ssTax = grossPay * SOC_SEC_TAX_RATE;
netPay = grossPay - (fedTax + stateTax + ssTax);

System.out.println ("\nPay Stub:");
System.out.println (" Hours worked: " + (regularHours + overtimeHours));
System.out.println (" Hourly rate: " + currencyFormat.format(hourlyRate));
System.out.println (" Gross pay: " + currencyFormat.format(grossPay));

System.out.println (" Federal tax: " + currencyFormat.format(fedTax)
+ " @ " + percentFormat.format(FED_TAX_RATE));

System.out.println (" State tax: " + currencyFormat.format(stateTax)
+ " @ " + percentFormat.format(STATE_TAX_RATE));

System.out.println (" Soc Sec tax: " + currencyFormat.format(ssTax)
+ " @ " + percentFormat.format(SOC_SEC_TAX_RATE));

System.out.println (" Net pay: " + currencyFormat.format(netPay));
System.out.println ();
}
}

Recommended Answers

All 3 Replies

ever time i put while before regular hours i get boolean is either true or false or somethings i just it runs but nothing shows up

1. put code in code tags
2. where are any of your while loops in the code

Being helped already over here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.