Results 1 to 3 of 3
Thread: Payroll Part 2, Java
- 03-24-2008, 07:33 AM #1
Member
- Join Date
- Feb 2008
- Posts
- 2
- Rep Power
- 0
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
- 03-24-2008, 07:35 AM #2
Member
- Join Date
- Feb 2008
- Posts
- 2
- Rep Power
- 0
Just to let you know. On the error message, the little '^' is actually under the bracket next to the left of the semi-colon. I don't know why it didn't copy over right...thanks again for your help.
- 03-24-2008, 01:55 PM #3
Similar Threads
-
help for payroll project in java
By mageshwari in forum New To JavaReplies: 2Last Post: 04-09-2008, 02:46 AM -
How to get part of a String?
By eva in forum New To JavaReplies: 1Last Post: 12-23-2007, 06:58 AM -
Inventory part 2 help please
By badness in forum New To JavaReplies: 1Last Post: 12-12-2007, 07:51 AM -
Help with mathematical part in java
By lenny in forum Advanced JavaReplies: 3Last Post: 08-09-2007, 01:55 PM -
Part time java Programmer-Indianapolis,IN
By pegitha in forum Jobs OfferedReplies: 0Last Post: 05-08-2007, 04:01 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks