-4

I am getting some "cannot find symbol" errors while trying to complile this java program and I am confused as to what is wrong. Here is a sample of the code...

public Employee(String empName, double hourlyRate, double regHours, double grossPay, double regPay, double netPay, double taxes, double otHours, double otPay, double totHours) {
        setEmpName(empName);
        setHourlyRate(hourlyRate);
        setRegHours(regHours);
        setGrossPay(grossPay);
        setRegPay(regPay);
        setNetPay(netPay);
        setTaxes(taxes);
        setOtHours(otHours);
        setOtPay(otPay);
        setTotHours(totHours);
    }

    //Set access methods
    public void setEmpName( String newEmpName ) {
        empName = newEmpName;

public String getEmpName() {
        return empName;
    }

I am getting errors on both the set and get methods, but cant figure out what I have done wrong.

EDIT: Here is what the compiler shows me for each line....there is a little arrow point to the lower case "e" on both empName statements.

error: cannot find symbol empName = newEmpName;

error: cannot find symbol return empName;

Mike Rose
  • 1
  • 3
  • 3
    Start by reading the error message. Isn't it the second time today you're asking a question about an error without saying what the error is? – JB Nizet Feb 03 '13 at 17:55
  • I actually understand what the error msg means, but I do not see where there is an error with the case sensitivity in this code nor do I see where the var isnt defined in the class. So i cant figure out why im getting the error. And I am saying exactly what the error is..its stated in the title AND the post. – Mike Rose Feb 03 '13 at 18:04
  • The compiler error is not just "you have some cannot find symbol errros". It says WHICH symbol can't be found, and at which line an column of the file the error is detected. You didn't post that information, and you didn't post the whole code (and you even posted code that wasn't the real one). The error message matters. Copy and paste it, instead of re-typing it. Same for your code. – JB Nizet Feb 03 '13 at 18:18

1 Answers1

2

It appears that your forgot to declare your class members:

public class Employee {
    private String empName;
    private double hourlyRate;
    // ... etc...

}
Alexandru Chirila
  • 2,274
  • 5
  • 29
  • 40
  • I have the brace in my code actually, it just didnt copy when I tried to paste it. There are more listings of the set instance after the emp name, I just didnt list them all, they are all getting the same error. And I cant use an IDE, taking a class in college for Java and they said we can only use a text editor :( – Mike Rose Feb 03 '13 at 18:03
  • then post the error, how else can we figure out what is wrong, and I hardly see the point of writing Java code in an text editor, when there are free IDE's like Netbeans and Eclipse. Also, I don't see how your teachers will tell the difference. – Alexandru Chirila Feb 03 '13 at 18:04
  • isnt "cannot find symbol" the error? I posted it in two different spots. Or do you mean where the error is in the code? I will edit my post with that info, sorry didnt think that would make a difference. – Mike Rose Feb 03 '13 at 18:09
  • 1
    just post the whole exception stack – Alexandru Chirila Feb 03 '13 at 18:10