Results 1 to 6 of 6
  1. #1
    jamesr2b is offline Member
    Join Date
    Jul 2007
    Posts
    9
    Rep Power
    0

    Default Help Finding Compiler error solution please

    When I try to run javac to compile this code i get 2 errors. Please help if you can.
    Code:
    public class PayrollProgramExecute
    {
    // main method
    public static void main( String args[] )
    {
    // Display welcome message
    PayrollProgram myPayrollProgram = new PayrollProgram( "Payroll Program" );

    myPayrollProgram.displayMessage(); // display first message
    myPayrollProgram.determineWeeklyRate(); // find weekly rate

    } // end main method

    } // end class




    Second Code:

    import java.util.Scanner; // program uses Scanner

    public class PayrollProgram

    {
    private String employeeName; // Employee Name

    // constructor start
    public PayrollProgram( String name )

    {

    employeeName = name; // initializes


    } // end constructor

    // method to store the employee name
    public void setEmployeeName( String name )
    {

    employeeName = name;

    } // end method

    setEmployeeName
    // method to retrieve the employee name
    public String getEmployeeName();

    {
    return employeeName;

    } // end method

    getEmployeeName

    public void displayMessage();

    {

    System.out.println( "\nWelcome to the Payroll Program.\n" );
    System.out.printf( "Please enter the employee name or \"stop\" to quit the program: ");
    }

    public void determineWeeklyRate();

    {

    // create Scanner to obtain input from command =window
    Scanner input = new Scanner( System.in );
    double hourlyRate;
    double hoursForWeek;
    double sum;

    while (input.hasNext( ))

    {
    employeeName = input.nextLine();
    if (!employeeName.equals("stop"))


    {

    // Hourly rate
    system.out.print("Please enter the employee\'s hourly rate: " );
    hourlyRate = input.nextDouble(); // input rate
    if (hourlyRate >= 0);
    else
    {
    System.out.println( "Hourly rate must be a positive value." );
    System.out.printf( "Please enter the employee\'s hourly rate: " );
    hourlyRate = input.nextDouble(); // input rate


    }

    // Hours worked per week
    System.out.print( "Please enter the employee\'s number of hours worked for that week: " );
    hoursForWeek = input.nextDouble(); // input hours for week
    if(hoursForWeek >= 0);
    else

    {

    System.out.println( "Hours worked for that week must be a positive value." );
    System.out.print( "Please enter the employee\'s number of hours worked for that week: " );
    hoursForWeek = input.nextDouble(); // input hours for week
    }
    sum = hourlyRate * hoursForWeek; // Calculate
    // Print employee's name and weekly pay amount.
    System.out.printf( employeeName ); // insert employee name
    System.out.printf( " made a total of " );
    ystem.out.printf( "\u0024" ); // insert unicode for $
    System.out.printf( " %.2f", sum ); // display sum
    System.out.printf( " for that week.\n\n" );
    System.out.printf( "Please enter the employee name or \"stop\" to quit the program: " );
    employeeName = input.nextLine();
    }
    else
    {
    System.out.println( "Bye.\n" );
    break;
    }
    }
    } // end method
    } // end class








    Errors:

    C:\>javac PayrollProgram.java
    PayrollProgram.java:27: <identifier> expected
    setEmployeeName;
    ^
    PayrollProgram.java:36: <identifier> expected
    getEmployeeName;
    ^
    2 errors

    C:\>javac PayrollProgramExecute.java
    PayrollProgramExecute.java:11: <identifier> expected
    PayrollProgram myPayrollProgram = new =PayrollProgram( "Payroll Pr
    ogram" );
    ^
    PayrollProgramExecute.java:11: '(' or '[' expected
    PayrollProgram myPayrollProgram = new =PayrollProgram( "Payroll Pr
    ogram" );
    ^
    2 errors

    C:\>

  2. #2
    valery is offline Member
    Join Date
    Jul 2007
    Posts
    32
    Rep Power
    0

    Default

    The first error I put them in red
    maybe you forgot to comment them
    Java Code:
    public void setEmployeeName( String name )
    {
    
    employeeName = name;
    
    } // end method
    
    [COLOR="Red"]setEmployeeName[/COLOR]
    // method to retrieve the employee name
    public String getEmployeeName();
    
    {
    return employeeName;
    
    } // end method
    
    [COLOR="Red"]getEmployeeName[/COLOR]
    
    public void displayMessage();

  3. #3
    shameel is offline Member
    Join Date
    Jul 2007
    Posts
    9
    Rep Power
    0

    Default

    i think valery is right . and second one is "PayrollProgram myPayrollProgram = new =PayrollProgram( "Payroll Pr
    ogram" );" here u just confirm this area with ur code , have to be "PayrollProgram myPayrollProgram = new PayrollProgram( "Payroll Pr
    ogram" );"
    .might be u r right ,but u didnt save ur file before compiling.
    thanx.
    chek it.

  4. #4
    tlouvierre is offline Member
    Join Date
    Apr 2009
    Location
    I live Stafford Texas right outside of Houston.
    Posts
    78
    Rep Power
    0

    Default

    I see code and I see errors but I am not seeing an explantion as to why it is wrong. Please help me to understand why the code is wrong in the first is it that it does not have a method?

  5. #5
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default Zombie alert !!!

    tlouvierre... you're asking questions on a post that is a year and half old. I would suggest you open a new post, asking a question and you can reference this older post in your new post.

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    I hate to say it, but this is completely farked up code created by a newbie. If I were you, I wouldn't study bad code, but instead concentrate on either examples of good code or your own code.

Similar Threads

  1. How to solve "No compiler error"?
    By iceman in forum New To Java
    Replies: 5
    Last Post: 04-22-2008, 04:37 AM
  2. compiler
    By jidd in forum New To Java
    Replies: 3
    Last Post: 01-29-2008, 01:40 PM
  3. Compiler Error
    By jeneal in forum New To Java
    Replies: 5
    Last Post: 12-13-2007, 02:31 PM
  4. Asking for the compiler
    By fernando in forum Other IDEs
    Replies: 1
    Last Post: 08-06-2007, 10:04 AM
  5. Replies: 1
    Last Post: 06-15-2007, 05:42 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
  •