//Payroll2
//Rachel Wells IT215
import java.util.Scanner;// program to use import scanner
public class Payroll2
{
//main method begins execution of java program execution
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)
{
// create scanner to obtain input from command window
Scanner input = new Scanner(System.in );
System.out.println(); // outputs a blank line
System.out.print( "Please enter Employee's Name or stop to exit program: " );
String empName = input.nextLine(); // employee name
if ( empName.equals("stop"))
{
System.out.println( "Exiting Program" );
stop = true;
}//end if
else
{
float hourlyRate; // hourly rate
float hoursWorked; // hours worked
float weeklyPay; // Weekly Pay for employee
System.out.print( "Please 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 value. " +
"Please enter the hourly rate again: " );
hourlyRate = input.nextFloat(); // read hourly rate again
}//end while
System.out.print( "Please enter hours worked: " ); // prompt for hours worked
hoursWorked = input.nextFloat();
while (hoursWorked <= 0) // prompt until positive value is entered
{
System.out.print( "Hours worked must be a positive value. " +
"Please re-enter hours worked: " ); // prompt for positive value
hoursWorked = input.nextFloat(); //
}//end while
{ // Calculate Weekly Pay.
weeklyPay = (float) hourlyRate * hoursWorked; // * sum
// Display Output Results and sum
System.out.print( empName ); // display employee name
System.out.printf( "'s weekly pay is: $%,.2f\n", weeklyPay); //display weeklypay
// end method main
// end class Payroll2