|
Payroll Part 2, Java
Hi, I'm hoping someone can please help me with this one nagging error in my program. I have to modify the program (from Part 1) so that it continues to request employee info until the user enters 'stop' as an employee name. Also the program has to check to see that both the hourly rate and numbers of hours worked are positive numbers. If they aren't positive, the application should let the user know to enter a positive number. As far as the error goes, I've tried looking for a missing semi colon, an imbalance or junk on previous lines or missing concatenation operatives...plleeeaaaassse help.
Here's my error:
C:\Documents and Settings\Leonard Lopez\Desktop\PayRoll2.java:36: ';' expected
name.setName = input.nextLine());
^
1 error
Tool completed with exit code 1
Here is my program:
// Fig 2.3: PayRoll2.java
// Payroll for Acme Company.
/* This is a payroll program for Acme Company*/
import java.util.Scanner;
public class PayRoll2
{
private static void Quit()
{
System.out.println( "Sign Off" );
System.exit (0);
}
// main method begins execution of Java application
public static void main( String args[] )
{
// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );
// create a Payroll object and assign it to PayRoll
double hourlyRate = 0.0; //employees hourly rate of pay
double hoursWorked = 0.0; //total of hours worked during the week
double pay = 0.0; //product of hoursWorked and hourlyRate
String name = "";
if (name.setName().equals( "Stop" ))
{
System.outprintln( "Stop is entered" );
Stop = true;
} //end if
else
System.out.print( "Please Enter Employees Name:" );
name.setName = input.nextLine());
if (name.getName().equals( "Stop"))
{
System.out.println( "Stop is entered" );
Stop = true;
} //end if
else
System.out.print( "Please Enter Total Number of Hours Worked This Week: ");
hoursWorked = input.nextDouble();
if ( hourlyRate < 0.0 );
System.out.println( "Input must be a positive number, reenter hourly rate: ");
System.out.println( "Please Enter Employees Hourly Rate: "); //prompt hourlyRate = input.nextDouble();
pay = hourlyRate * hoursWorked;
System.out.printf( "Employee Name: %s\n",name );
System.out.printf( "Total Pay for the Week: $%.2f\n",pay);
} //end method main
} //end class PayRoll2
|