I think I have 90+ percent of the coding right for this but I
am having an issue with the program stopping after the "welcome to payroll program statement"

I can't figure out what goes after while on the liine after the boolean stop line.

Any help would be greatly appreciated!!

IKE

package employee_pay;

// Payroll program calculates employee's weekly pay.

import java.util.Scanner;

public class pay{
        public static void main( String args[] )
{
System.out.println( "Welcome to the Payroll Program!" );

boolean stop = false; // Loop until user types "stop" as the employee name.
while (!stop);
{
Scanner input = new Scanner(System.in );

System.out.println(); 
System.out.print( "Enter Employee's Name or stop to exit program: " );
String empName = input.nextLine(); 

if ( empName.equals("stop"))
{
System.out.println( "Program Exited" );
stop = true;
}
else
{
float hourlyRate; // hourly rate
float hoursWorked; // hours worked
float weeklyPay; // Weekly Pay for employee

System.out.print( "Enter hourly rate: " ); // prompt for hourly rate
hourlyRate = input.nextFloat();

while (hourlyRate <= 0) // prompt until positive value is entered
{
System.out.print( "Hourly rate must be a positive number. " +
"Please enter the hourly rate again: " );
hourlyRate = input.nextFloat(); // read hourly rate again
}

System.out.print( "Enter hours worked: " ); // prompt for hours worked
hoursWorked = input.nextFloat();


while (hoursWorked <= 0) // prompt until a positive value is entered
{
System.out.print( "Hours worked must be a positive number. " +
"Please re-enter hours worked: " ); // prompt for positive value for hours worked
hoursWorked = input.nextFloat(); // read hours worked again
}

// Calculate Weekly Pay.

weeklyPay = (float) hourlyRate * hoursWorked; // multiply sum

// Display Output Results and sum

System.out.print( empName ); // display employee name
System.out.printf( "'s weekly pay is: $%,.2f\n", weeklyPay); // display weekly pay

}
}

// Display ending message:
System.out.println( "Closing Payroll Program." );
System.out.println(); // outputs a blank line

} // end method main

} // end class Pay

hahaha this is a really unfortunate error:

while (!stop);{

notice the semicolon (hence an infinite loop of empty statement)

So do I need to delete the semicolon?
OR what do I need to change?

Thanks

IKE

Delete it.

Also consider formatting your code properly:

package employee_pay; 

import java.util.Scanner;

public class pay
{
  public static void main ( String args[] )
  {
    System.out.println ( "Welcome to the Payroll Program!" );

    boolean stop = false;
    while ( !stop )
    {
      Scanner input = new Scanner ( System.in );

      System.out.println();
      System.out.print ( "Enter Employee's Name or stop to exit program: " );
      String empName = input.nextLine();

      if ( empName.equals ( "stop" ) )
      {
        System.out.println ( "Program Exited" );
        stop = true;
      }
      else
      {
        float hourlyRate;
        float hoursWorked;
        float weeklyPay;

        System.out.print ( "Enter hourly rate: " );
        hourlyRate = input.nextFloat();

        while ( hourlyRate <= 0 )
        {
          System.out.print ( "Hourly rate must be a positive number. " +
                             "Please enter the hourly rate again: " );
          hourlyRate = input.nextFloat();
        }

        System.out.print ( "Enter hours worked: " );
        hoursWorked = input.nextFloat(); 
        while ( hoursWorked <= 0 )
        {
          System.out.print ( "Hours worked must be a positive number. " +
                             "Please re-enter hours worked: " );
          hoursWorked = input.nextFloat();
        } 

        weeklyPay = ( float ) hourlyRate * hoursWorked; 

        System.out.print ( empName );
        System.out.printf ( "'s weekly pay is: $%,.2f\n", weeklyPay );

      }
    } 
    System.out.println ( "Closing Payroll Program." );
    System.out.println();
  }
}

Thank you very muc for your assistance with this.

I really appreciate it!

COY

This question has already been answered. Start a new discussion instead.