I am in a beginners Java programming class. So far I am doing ok in the class, although there are some things that I am sure will come in time. Right now we are doing an onging project that started with a basic payroll application. Every week we build on it. I am having some troubles with this week. The idea of the program is to continue to request the employees information until the user enters 'stop' as the employee name. I keep getting an error message when I compile it.
Here is what I have:
// Payroll22.java
// Payroll program that displays the weekly pay of employee.
import java.util.Scanner; // program uses class Scanner // Author: Nicki
public class Payroll22
{
// main method begins execution of Java application
public static void main( String args[] )
String name = input.next();
double rate = input.nextDouble();
double hours = input.nextDouble();
{
// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );
// prompt for and input employee name
System.out.printf( "Enter the employee name:\n" );
while (!name.equalsIgnoreCase("stop"))
{
// Hourly Rate input
System.out.printf( "Enter the employee's hourly rate in dollars:\n" );
while ( rate < 0 )
{
System.out.printf( "Please enter a positive value:" );
rate = input.nextDouble( );
} // end while loop (pay rate)
// Hours Worked input
System.out.printf( "Enter the number of hours worked:\n" );
while ( hours < 0 )
{
System.out.printf( "Please enter a positive value:" );
hours = input.nextDouble( );
} // end while loop (hours worked)
// Output the result
System.out.printf( "Employee: " + name + "\n" );
System.out.printf( "Pay: $%.2f", rate*hours );
// prompt for and input employee name
System.out.printf( "Enter the employee name:" );
} // end while loop
} // end method main
} // end class Payroll22
The error that shows up has to do with line 9 and it says the following:
' ; ' expected public static void main ( String args[] )
The arrow is pointing to the space after the last parenthesis.
Any ideas what I could be doing wrong? I have a feeling it is something obvious that I keep overlooking because I have looked at it too long.
Thank you for your help!
Nicki