wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes connot resolve symbol-variable calculate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "connot resolve symbol-variable calculate" Watch "connot resolve symbol-variable calculate" New topic
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: 24183
    
  34


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
 
wood burning stoves
 
subject: connot resolve symbol-variable calculate
 
Similar Threads
Problem converting a String to java.util.Date
method call not responding correctly
date
Converting From String to java.sql.Date
string to date