I have worked on this class all last night and I am having trouble finding the problem. When I compile this file I am recieving errors and I do not understand what is the problem. Here is the program code:

public class Employee

{
  private String employeeName; //name of employee
  private int hours;  // when used double here errors occured.
  private int rate;
  private int pay;

    // constructor to initialize employeeName
    public Employee( String name )
       {
         employeeName = name; // initializes employeeName
       } // end constructor
   

          // method to set employee name
          public void setEmployeeName( String name )
              {
                 employeeName = name;
              } // end method setEmployeeName
    

          // method to set hours worked
          public double setHours()
              {
                hours worked = hours;
              } // end method setHours


          // method to set wage rate
          public double setRate()
              {
                wage rate = rate;
              } // end method setRate
 
         


          // method to retrieve employee name
          public String getEmployeeName()
              {
                 return employeeName; 
              } // end method getEmployeeName
           
          
          // method to retrieve hours worked
          public double getHours()
              {
                 return hours;
              } // end method getHours


          // method to retrieve wage rate
          public double getRate()
              {
                 return rate;
              } // end method getRate

           
          // method to retrieve pay total
          public double getPay()
              {
                 return pay;
              } // end method getPay

} // end Employee class

Here are the 2 errors that I am recieving from the compiler:

cannot find symbol
symbol : class hours
location : class Employee
hours worked = hours;
^

cannot find symbol
symbol : class rate
location : class Employee
wage rate = rate;
^


I do not know if I am overlooking something that I know to do because I am so tired or what. But I am not sure what symbol it can't find. Help would be appreciated.

Sincerely,

Here are your variable names. If it's not in this list and it's not a local variable, JAVA can't find it:

private String employeeName; //name of employee
  private int hours;  // when used double here errors occured.
  private int rate;
  private int pay;

Here's your function:

public double setHours()
              {
                hours worked = hours;
              } // end method setHours

What is hours worked ? Is it a variable name? If so, it's two separate words, so you need an underscore to make it a legal variable name: hours_worked . However, hours_worked isn't a data member of the Employee class, so you are still going to get the error. You also have a function that says it returns a double not returning anything. set functions usually don't return anything. Are you sure you don't mean to do something like this?

public void setHours(int hours_worked)
              {
                   hours = hours_worked;
              } // end method setHours

Note that hours_worked is an int to match the type of hours .

Thank you! That was a big help. I had my wires crossed and did it backwards. I also forgot about void when setting variables to retrieve the users input. I feel a little stupid because I knew all that but thanks for pointing out my mishap. I think I have been working so hard that I confused my self by overthinking it in some areas and underthinking in others.
Thanks again.
Sincerely,

This question has already been answered. Start a new discussion instead.