import java.util.Scanner; // program uses class Scanner
public class NewClass5 {
/**
* @param args the command line arguments
*/
// main method begins execution of java application
public static void main( String args[] )
{
System.out.println( "Welcome to the Payroll Program " );
boolean stop = false; // This flag will control whether we exit the loop
// 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 the employee name or stop to end program: " );
// prompt for and input employee name
String empName = input.nextLine(); // read employee name
if ( empName.equals("stop")) // Check whether user indicated to stop program
{
stop = true;
}
else
{
// User did not indicate to stop, so continue reading info for this iteration:
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(); // read hourly rate
while (hourlyRate <= 0) // prompt until a positive value is entered
{
System.out.print( "Hourly rate must be a positive value. " +
"Please enter the hourly rate again: " ); // prompt for positive value for hourly rate
hourlyRate = input.nextFloat(); // read hourly rate again
}
System.out.print( "Enter hours worked: " ); // prompt for # of hours
hoursWorked = input.nextFloat(); // read # of hours
while (hoursWorked <= 0) // prompt until a positive value is entered
{
System.out.print( "Hours worked must be a positive value. " +
"Please enter the hours worked again: " ); // prompt for positive value for hours worked
hoursWorked = input.nextFloat(); // read hours worked again
}
// Move on to calculate Weekly Pay.
weeklyPay = (float) hourlyRate * hoursWorked; // multiply the hourly rate by the hours worked
// Display output
System.out.println(); // outputs a blank line
System.out.print( empName ); // display employee name
System.out.printf( "'s weekly pay is: $%,.2f\n", weeklyPay); // display weekly pay
System.out.println(); // outputs a blank line
}
}
// Display ending message:
System.out.println( "Program ended" );
System.out.println(); // outputs a blank line
} // end method main
} // end class Payroll1
Above is my payroll program and works to this point. My next step is
create a class to store and retrieve the information within the program.
I am lost and could use some pointers without actually doing the work.