?
Solved

Error message (cannot resolve symbol)

Posted on 2001-08-04
5
Medium Priority
?
189 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 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month14 days, 10 hours left to enroll

770 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