Forums Register Login

Cannot find symbol error

+Pie Number of slices to send: Send
cannot find symbol

symbol: method calculateTotalCompensation(double)
location: variable Salesperson1 of type Salesperson1

thus error is on line 39 and 46

1
+Pie Number of slices to send: Send
On this line

The variable name you chose is the same as the class name. This is legal but it's very bad form.  By convention, variable and method names in Java start with a lowercase letter. That helps you distinguish them from class, interface, and enum type names. When you use "Salesperson1" as a variable name, it makes the reader work much harder to figure out whether you're referring the variable or the class.

On line 32, you are attempting to invoke Salesperson1.calculateTotalCompensation(sales).  That's a method call, except there is no such method defined in your Salesperson1 class. That's what "Symbol not found" means. The "symbol" being referred to is the name "calculateTotalCompensation"
+Pie Number of slices to send: Send
Line 39 and 34 corrected but line 32 is still giving me problems with the symbol not found. I'm not sure how to correct it?
+Pie Number of slices to send: Send
Well, if you tell someone to reach into your pocket and that person says to you, "How do I do that, you don't have any pockets!" you probably want to go and put on an article of clothing that does have a pocket, right?

In the same way, if you tell Java to call a method and Java says, "How do I do that, your program doesn't have such a method!" what do you think you should do?

Do you know how to define methods in Java?
+Pie Number of slices to send: Send
would i create a method for calculateTotalCompensation? or a method for salesperson?
+Pie Number of slices to send: Send
 

Junilu Lacar wrote:On line 32, you are attempting to invoke Salesperson1.calculateTotalCompensation(sales).  That's a method call, except there is no such method defined in your Salesperson1 class. That's what "Symbol not found" means. The "symbol" being referred to is the name "calculateTotalCompensation"


Here you are being told what method is missing.
+Pie Number of slices to send: Send
I am kinda self taught and am having a hard time learning this so I need it spelled out to me. I understand that some people can tell whats what but I have literally never done this before. So any help is greatly appreciated, i need to be tutored through this whole process.
+Pie Number of slices to send: Send
Then perhaps you should first go look at the Tutorial that I cited earlier, on how to define methods. Please remember, we're all volunteers here. If someone is willing to go the extra mile to tutor you step-by-step, that's fine. That's not normally what happens in these forums though. People just come here for tips and hints or further information that they can't find in more in-depth references like online tutorials or books.
+Pie Number of slices to send: Send
By all means, check out the link provided. Some great stuff in there.

When you see something like
It is telling you that there should be a method named "calculateTotalCompensation" in your "Salesperson1" class and that it should have exactly one argument that is the same type as your "sales" variable.

Additionally, you have to determine if you declare the method as being "static" or not. If you see a method being called like this:
then it is an instance method, i.e. not static. If it is being called like
it is a static method. Note that you should look up "static" in the links provided to get a better understanding.

Then you need to declare the return type of the method(). If you don't need to return any data then use "void". If you do need to return data then your design or requirements will dictate what return type to use. Sometimes the return type can be inferred by looking to see how the method is being used, but not always.
Shiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 990 times.
Similar Threads
if statements
public static main void issue
Input into a method
Initialization and "While"
Java and netbean week 3 Salesperson Java™ Application Part II
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 00:33:23.