| Author |
connot resolve symbol-variable calculate
|
Valarie Brandt
Greenhorn
Joined: Oct 03, 2003
Posts: 24
|
|
i am getting the above error message when i try to compile. calculate is not a variable it is a method but invoiceDate is a method also so i don't see where i went wrong any help that can be offered would be appreciated. (invoice method which works fine) public void invoiceDate() { invoiceDate = new Date(); SimpleDateFormat formatter = new SimpleDateFormat(); String dateString = formatter.format(invoiceDate); System.out.println(dateString); } public double calculate() { double calculate; calculate = quantity * price; return calculate; } public void display() { System.out.println("The invoice date is: "+ invoiceDate + "\nItem Name: " + name + "\nQuantity: " +quantity + "\nPrice per item is : " + price + "\nThe total price is: " + calculate + "."); }
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24057
|
|
Here there's a method named invoiceDate() that uses a variable named invoiceDate,. This method assigns a value to a variable "invoiceDate" in the first line, but I don't see a declaration for that variable; it would be OK it if were a member, but if not, then you need to say "Date invoiceDate = ..." This method is fine if quantity and price are member variables; otherwise, it's going to have the same problems. This method refers to variables named invoiceDate and calculate; I strongly suspect you mean to call the functions invoiceDate() and calculate() here instead like OK?
|
[Jess in Action][AskingGoodQuestions]
|
 |
Valarie Brandt
Greenhorn
Joined: Oct 03, 2003
Posts: 24
|
|
thank you so much--You helped me realize that i needed to call the method name and the method name includes the () right? thank you Val
|
 |
 |
|
|
subject: connot resolve symbol-variable calculate
|
|
|