Results 1 to 4 of 4
  1. #1
    blondielox is offline Member
    Join Date
    Aug 2011
    Posts
    2
    Rep Power
    0

    Default Working on Payroll Program Part 2 and getting multiple errors

    I am trying to work on modifying payroll program part 1 and my code is not working. Not sure what I am missing and not really understanding the error messages. Can someone please look at my code and tell me what I am doing wrong?

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package payrollprogram;

    /**
    *
    * @author
    */

    import java.util.Scanner;

    public class PayrollProgram {

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
    // declare variables

    String employeeName;
    double hourlyPay;
    double hoursWorked;
    double weeklyPay;
    double overtimeHours;
    double overtimeRate;
    double overtimePay;
    double totalHours;
    boolean stop = false;

    //create scanner to imput data
    java.util.Scanner input = new Scanner(System.in);

    while (stop == false)
    {
    // prompt for employee name or the word stop to exit
    System.out.print("Please enter the Employee's name or stop to exit the program: ");
    employeeName=input.nextLine();
    if (employeeName.equalsIgnoreCase("stop"));
    {
    System.out.println("Exiting Program");
    stop = true;
    }// ends if statement
    else
    {
    //prompt for hourly rate
    System.out.println("Please enter the employee's hourly rate of pay: ");
    hourlyPay = input.nextDouble();
    }//end else
    while (hourlyPay < 0) //checks for a negative value
    {
    System.out.println("Please enter a positive number: ");
    hourlyPay = input.nextDouble();
    }//end while statement

    System.out.println("Please enter the number of hours worked for this employee: ")// prompt for number of hours worked
    hoursWorked = input.nextDouble();

    while (hoursWorked < 0)// checks for a negative value
    {
    System.out.println("Please enter a positive number: ");
    hoursWorked = input.nextDouble();
    }//end while
    if (hoursWorked > 40) // determines if employee has overtime
    {
    //calculate pay
    weeklyPay = hoursWorked*hourlyPay
    overtimePay = (hoursWorked - 40)*(hourlyPay*1.5)
    totalHours = hoursWorked + overtimeHours



    //if employee has overtime display information

    System.out.println("Employee: " + employeeName);
    System.out.printf("Hourly pay rate: $%.2f\n", hourlyPay);
    System.out.println("Total number of hours worked: " + totalHours);
    System.out.printf("Weekly pay: $%.2f\n", weeklyPay+overtimePay)
    }//end if

    else
    // if employee does not have overtime display information
    {
    System.out.println("Employee: " + employeeName);
    System.out.printf("Hourly pay rate: $%.2f\n", hourlyPay);
    System.out.println("Total number of hours worked: " + hoursWorked);
    System.out.printf("Weekly pay: $%.2f\n", weeklyPay)
    }

    }//end while




    }//end method main
    }//end class PayrollProgram

    These are the errors I am receiving:

    java.lang.ClassFormatError: Duplicate field name&signature in class file payrollpgm/PayrollPgm
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader. java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java :615)
    at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader .java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader. java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 47)
    Could not find the main class: payrollpgm.PayrollPgm. Program will exit.
    Exception in thread "main" Java Result: 1
    BUILD SUCCESSFUL (total time: 1 second)

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    What command line did you enter to get that error message?
    Can you post the FULL contents of the command prompt window from when you executed the program?

    I've never seen that error message before.

  3. #3
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    I'm not sure where you are getting your error message(s) from. When I compiled your code it gave an "else without if statement" error.
    Java Code:
    if (employeeName.equalsIgnoreCase("stop"));
    {
        System.out.println("Exiting Program");
        stop = true;
    }// ends if statement
    else
    Hmmmm!

  4. #4
    blondielox is offline Member
    Join Date
    Aug 2011
    Posts
    2
    Rep Power
    0

    Default

    I am using NetBeans to do my work. This is what the teacher recommended. I am closing out the application and will re-open it and try to start again. Not sure what is going on with it ???

Similar Threads

  1. payroll program 2
    By joshwey in forum New To Java
    Replies: 13
    Last Post: 05-13-2011, 09:27 AM
  2. Payroll part 3 errors help
    By arrech326 in forum New To Java
    Replies: 4
    Last Post: 03-08-2011, 05:43 AM
  3. Payroll program
    By bigley04 in forum Eclipse
    Replies: 7
    Last Post: 12-06-2010, 04:57 PM
  4. Need help ASAP with Payroll Program Part 2
    By arrech326 in forum New To Java
    Replies: 10
    Last Post: 11-17-2009, 10:17 PM
  5. Payroll Part 2, Java
    By lplopez92 in forum New To Java
    Replies: 2
    Last Post: 03-24-2008, 01:55 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
  •