Solved

Error message (cannot resolve symbol)

Posted on 2001-08-04
5
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
hibernate example using maven 12 106
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 94
java imports not found 4 71
Setup GlassFish 4 55
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses

734 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