Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Payroll Program Part 2 help

843785Jan 31 2009 — edited Jan 31 2009
Hello,

This is what I have and I was able to compile it. However, when I tried to run the program, it only gave me the welcome message.
It did not even prompt me to press enter to proceed to the next step...

I don't know what I am missing.. I need somebody's help!

Thanks you so much in advance!

---------


// PayrollProgramPart2.java
// A non-GUI based Java application that calculates weekly pay for an employee.
// Author:MMM
// 01/30/2009

import java.util.Scanner;

public class PayrollProgramPart2
{
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.print( "Enter Employee's Name or stop to exit program: " );
String empName = input.nextLine(); // employee name

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

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

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.nextDouble(); // read hourly rate again
}

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


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.nextDouble(); // read hours worked again
}

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

System.out.printf( "%s%.2f\n",
"Employee: " + empName + " Weekly Pay:", weeklyPay ); // display employee's weekly gross income in U.S. dollar

}
}

} // end method main

} // end class PayrollPart2
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 28 2009
Added on Jan 31 2009
11 comments
209 views