Results 1 to 3 of 3
  1. #1
    lplopez92 is offline Member
    Join Date
    Feb 2008
    Posts
    2
    Rep Power
    0

    Default 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

  2. #2
    lplopez92 is offline Member
    Join Date
    Feb 2008
    Posts
    2
    Rep Power
    0

    Default

    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.

  3. #3
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Java Code:
    C:\jexp>javac pr2.java
    pr2.java:33: ';' expected
    name.setName = input.nextLine());
                                   ^
    1 error
    On line 33 change this
    Java Code:
    name.setName = input.nextLine());
    to this
    Java Code:
    name.setName = input.nextLine();

Similar Threads

  1. help for payroll project in java
    By mageshwari in forum New To Java
    Replies: 2
    Last Post: 04-09-2008, 02:46 AM
  2. How to get part of a String?
    By eva in forum New To Java
    Replies: 1
    Last Post: 12-23-2007, 06:58 AM
  3. Inventory part 2 help please
    By badness in forum New To Java
    Replies: 1
    Last Post: 12-12-2007, 07:51 AM
  4. Help with mathematical part in java
    By lenny in forum Advanced Java
    Replies: 3
    Last Post: 08-09-2007, 01:55 PM
  5. Part time java Programmer-Indianapolis,IN
    By pegitha in forum Jobs Offered
    Replies: 0
    Last Post: 05-08-2007, 04:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •