area = (radius * 3.14)^2;
Two things: first, the area of a circle is PI * r^2 not (r * PI)^2. Secondly, the java compiler doesn't recognise the ^. You need to use the Math.pow method to raise something to a power, but in this case it is easier to just multiply PI by radius by radius.
darkagn
Veteran Poster
1,197 posts since Aug 2007
Reputation Points: 404
Solved Threads: 200
Which line is line 36 of your file?
darkagn
Veteran Poster
1,197 posts since Aug 2007
Reputation Points: 404
Solved Threads: 200
Ah, ok, you need to move your calcarea method inside the class.
EDIT: No wait, it is inside the class. This exception is usually raised when you miss closing a bracket or brace or miss a semi-colon. Double check your code to make sure that hasn't happened. Also "Double" should be "double" in the calcarea signature.
darkagn
Veteran Poster
1,197 posts since Aug 2007
Reputation Points: 404
Solved Threads: 200
just a few remarks:
you're calling the calcarea - method with a parameter, but you have no parameter calcarea that takes parameters
it should take the parameter 'double radius'
like this:
public static double calcarea(double radius)
{
area = (radius * 3.14)^2; // idd, don't just copy paste this, like I did :)
return(area);
}
also: count your closing brackets: your calcarea method is in your main method, and you don't have a closing bracket for the class
your method calcarea also does not know the local variable area, so a next improvement to your method above:
public static double calcarea(double radius)
{
<strong>double</strong> area = (radius * 3.14)^2; // idd, don't just copy paste this, like I did :)
return(area); // these brackets are not mandatory return area; is also correct
}
I don't know if there are any problems left, I haven't tested the app, but this should help you at least a bit further
d
stultuske
Posting Sensei
3,110 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 432