Results 1 to 7 of 7
  1. #1
    wizar is offline Member
    Join Date
    Nov 2010
    Posts
    18
    Rep Power
    0

    Default Keep on getting cannot find symbol errors...

    I am trying to write a class that will calculate employee payrolls, but I kept on getting cannot find symbol errors when compiling. I fixed some (I think) but I don't understand why I keep on getting those errors, and I think that the errors I thought I fixed will impact the rest of the program. Can anyone tell me what I am doing wrong?

    I have to output the variables, (deleted that for the moment). Before printing the variables, I know I would have to associate with the set methods, but would I have to create set methods for all the calculated values (like the taxes)?

    Java Code:
    public class Payroll
    {
      public static void main( String args [] )
      {
        String employeeNum; 
        double hours; 
        double payRate; 
        double grossPay = 0;
        double provW = 0;// tax money
        double fedW = 0;// tax money
        double provTax = 0.14;
        double fedTax= 0.17;
        double totalTax = 0;
        double netPay = 0;
        
        
        System.out.print( "Input the employee's number. 'end' to terminate:" ); 
        employeeNum = ReadLib.readString (); 
        
        while ( !employeeNum.equals("end") )
        {
          System.out.print( "Input the number of hours worked: " ); 
          hours = ReadLib.readDouble (); 
          
          System.out.print( "Input the employee's payrate: " ); 
          payRate = ReadLib.readDouble (); 
          
          
          Employee myEmployee = new Employee( employeeNum, payRate, hours );
          
          System.out.println(netPay);
          
          System.out.println(); 
          
          System.out.print( "Enter the employee's number. 'end' to terminate:" ); 
          employeeNum = ReadLib.readString(); 
          
        }
        
        System.out.println(); 
        
        System.out.println( "Program terminated by user." ); // exit message
        
      } // end main
      
    } // end class Payroll
    
    
    
    class Employee
    {
      String num; //employee number
      double payRate = 0; //pay rate
      double hours = 0; //number of hours worked
      
      Employee( String num, double rate, double hoursWorked ) //constructor
      {
        num = num; // pass employee's name
        payRate = rate; // pass rate of pay
        hours = hoursWorked; // pass number of hours worked
      } // end constructor
      
      public void setName ( String employeeNum ) // method to set employee name
      {
        num = employeeNum; // store 
      } // end method 
      
      public String getName() //retrieve employee num
      {
        return num;
      } // end method 
      
      public void setRate ( double hourlyRate ) 
      {
        payRate = payRate; 
      } 
      
      public double getRate() 
      {
        return payRate;
      } 
      
      public void setHoursWorked ( double hours ) 
      {
        hours = hours; 
      } 
      
      public double getHoursWorked() 
      {
        return hours;
      } 
      
      public double getGrossPay() 
      {
        return hours * payRate;
      } 
      
      //not sure at this point
      
      public double getProvW()
      {
        return grossPay * provTax;
      }
      
      public double getFedW()
      {
        return grossPay * fedTax;
      }
      
      public double getTotalTax()
      {
        return provW + fedW;
      }
      
      public double getNetPay()
      {
        return grossPay - totalTax;
      }
    } // end class Employee
    Last edited by wizar; 11-25-2010 at 02:53 AM.

  2. #2
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    4

    Default

    What are the exact errors (copied & pasted) that you are receiving?

  3. #3
    zab
    zab is offline Member
    Join Date
    Nov 2010
    Location
    Cebu City
    Posts
    1
    Rep Power
    0

    Default

    Why don't you try to consider my this program...I revised your program.. If you want to calculate something...then just create a method get in the Employee class...you'll figure the rest....good luck!!!


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

    package test;

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;

    /**
    *
    * @author bzit
    */
    public class Payroll{
    public static void main( String args [] ) throws IOException{

    String nameOfEmployee;
    int numOfEmpl;
    double hours;
    double payRate;
    double grossPay = 0;
    double provW = 0;// tax money
    double fedW = 0;// tax money
    double totalTax = 0;
    double netPay = 0;

    BufferedReader buff = new BufferedReader (new InputStreamReader(System.in));

    System.out.print( "Input the employee's number. 'end' to terminate:" );
    numOfEmpl = Integer.parseInt(buff.readLine());

    while ( numOfEmpl > 0){
    System.out.print( "Input the Employees : " );
    nameOfEmployee = buff.readLine();

    System.out.print( "Input the number of hours worked : " );
    hours = Double.parseDouble(buff.readLine());

    System.out.print( "Input the employee's payrate: " );
    payRate = Double.parseDouble(buff.readLine());

    Employee myEmployee = new Employee( nameOfEmployee, payRate, hours );

    System.out.println(myEmployee.getNetPay());

    System.out.println();
    numOfEmpl--;
    }

    System.out.println();

    System.out.println( "Program terminated by user." ); // exit message

    } // end main

    } // end class Payroll



    class Employee{
    String employeeName; //employee number
    double payRate = 0; //pay rate
    double hours = 0; //number of hours worked

    double provTax = 0.14;
    double fedTax = 0.17;

    public Employee(String employeeNumber, double payRate, double hours) {
    this.employeeName = employeeNumber;
    this.payRate = payRate;
    this.hours = hours;
    }

    public void setEmployeeNumber(String employeeNumber) {
    this.employeeName = employeeNumber;
    }

    public void setHours(double hours) {
    this.hours = hours;
    }

    public void setPayRate(double payRate) {
    this.payRate = payRate;
    }

    public String getEmployeeNumber() {
    return employeeName;
    }

    public double getHours() {
    return hours;
    }

    public double getPayRate() {
    return payRate;
    }

    public double getNetPay(){
    return payRate * hours;
    }

    public double getProvTax(){
    return provTax;
    }

    public double getFedTax(){
    return fedTax;
    }

    } // end class Employee

  4. #4
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    4

    Default

    It's wise to not just give code to people who ask questions, zab. This teaches them nothing and, in the situation where they are in school and trying to learn the material, will end up screwing them on the final exam.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by Zack View Post
    It's wise to not just give code to people who ask questions, zab. This teaches them nothing and, in the situation where they are in school and trying to learn the material, will end up screwing them on the final exam.
    I agreed with you. And I don't know what he really expecting by spending time and writing codes like this for others. This is not way to helping out them.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    @zab, please use code tags also if you are posting code segments next time in the forum. And a lighter color for your text too. Those kind of things are not encourage to read the code.

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Back to original question. wizar, did you try to read the error message you comes with? If you did that, you can have some kind of idea what the error is.

    And also provide more details easy for us like:


    Quote Originally Posted by Zack View Post
    What are the exact errors (copied & pasted) that you are receiving?

Similar Threads

  1. Cannot find symbol
    By Johanis in forum New To Java
    Replies: 19
    Last Post: 11-04-2010, 08:13 PM
  2. Still cannot find symbol!
    By Johanis in forum New To Java
    Replies: 1
    Last Post: 11-04-2010, 04:32 PM
  3. "Cannot find symbol" errors in Java
    By 23Zone in forum New To Java
    Replies: 1
    Last Post: 02-17-2010, 07:13 AM
  4. Replies: 9
    Last Post: 10-18-2008, 08:26 PM
  5. Replies: 3
    Last Post: 05-01-2008, 08:30 AM

Posting Permissions

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