Solved

Error message (cannot resolve symbol)

Posted on 2001-08-04
5
182 Views
Last Modified: 2010-03-31
Hi Folks, I'm having trouble getting my head around the error that I'm experiencing.
I know its only simple but until I can nail it it keeps nagging me.
Some code:-

//Numbers    


public class Numbers
{
     public static void main(String[] args)
     {
          int when, now;     //declare variables
          when=45;
          now=15;
         
          sum=calcSum(when, now);
          diff=calcDiff(when, now);
          prod=clacProd(when, now);
          System.out.println("Total is: " + sum);
          System.out.println("Difference is: " + diff);
          System.out.println("Product is: " + prod);
     }
     public static int calcSum(int w, int n)
     {
          int totSum;     //add the variables
          totSum=(w + n);
          return totSum;
     }
     public static int calcDiff(int w, int n)
     {
          int totDiff;     //get the difference
          totDiff=(w % n);
          return totDiff;
     }
     public static int calcProd(int w, int n)
     {
          int totProd;     //multiply the variables
          totProd=(w * n);
          return totProd;
     }
         
}    

This is some of the errors,

                ^
Numbers.java:14: cannot resolve symbol
symbol  : method clacProd  (int,int)
location: class Numbers
                prod=clacProd(when, now);
                     ^
Numbers.java:15: cannot resolve symbol
symbol  : variable sum
location: class Numbers
                System.out.println("Total is: " + sum);
                                                  ^
As you can see they are similar errrors, so I only need to get this and I'll be able to nail another concept(hopefully).
Regards Ned
0
Comment
Question by:Ned_Kelly
  • 2
  • 2
5 Comments
 

Author Comment

by:Ned_Kelly
ID: 6352732
This piece of code is very similar and it works, the maths might not be perfect but the app works.

//Picture

public class Picture
{
     public static void main(String[] args)
     {
          float height, width;     //declare types
          float cost, glass, met, squ;    
         
          squ=0.56f;     //Square is $56 divided by 1000 number of square cm
          met=28.50f;     //meter is $28.50 per lineal meter
          height=17.9f;
          width=24.6f;
          cost=calcCost(height, width);
          glass=calcGlass(height, width);
          System.out.println("Frame cost is: " + cost);
          System.out.println("Glass cost is: " + glass);
          System.out.println("Total cost for the picture is: " + (cost + glass) / 100 * 10);
     }
     public static float calcCost(float h, float w)
     {
          float totCost;
          totCost=(h * 2 + w * 2) * 28.50f;
          return totCost;
     }
     public static float calcGlass(float h, float w)
     {
          float totGlass;
          totGlass=(h * w) * 0.56f;
          return totGlass;
     }
}

Regards Ned
0
 
LVL 9

Expert Comment

by:yongsing
ID: 6352741
Here are your problems:

>> Numbers.java:14: cannot resolve symbol
>> symbol  : method clacProd  (int,int)
>> location: class Numbers
>>                prod=clacProd(when, now);
                    ^
The function name is "calcProd", not "clacProd"!

>> Numbers.java:15: cannot resolve symbol
>> symbol  : variable sum
>> location: class Numbers
>>                System.out.println("Total is: " + sum);
                                                 ^
The variables sum, diff, and prod are not defined. You should rewrite the statements as:

int sum=calcSum(when, now);
int diff=calcDiff(when, now);
int prod=clacProd(when, now);
0
 
LVL 9

Accepted Solution

by:
yongsing earned 50 total points
ID: 6352745
The last statement should be:

int prod = calcProd(when, now);

Also, you have a mistake in your calcDiff() method:

totDiff=(w % n);

You should change the % to a - sign.
0
 

Author Comment

by:Ned_Kelly
ID: 6353108
Thats great, thankyou yongsing, you were right in both instances.  The % sign was put there thinking that it was the difference that I wanted, not to worry.
I'm still not sure why the other app works though, is it because of the f behind the numbers in the code below.

  squ=0.56f;    
                                                             met=28.50f;    
                                                             height=17.9f;
                                                             width=24.6f;
                                                             cost=calcCost(height, width);
                                                             glass=calcGlass(height, width);

Or is it because its a different type.
Thanks again for a great answer.
Regards Ned
0
 
LVL 2

Expert Comment

by:vasan_sr
ID: 6353906
Hello sir,
   U have to declare the variable, and then use the variable.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 79
reasons why a "inside Menu" would not appear for a web server 6 56
JAVA part two 5 57
Checkbox and ListView in Android Layout 4 56
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This video teaches viewers about errors in exception handling.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now