+ 2
Error "cannot find symbol: variable area"
Have anybody help me 😭how can i solve this problem public static double circleArea (double r){ if (r>=0){ double area = Math.PI *Math.pow(r , 2.0); } return area; } cannot find symbol: variable area return area; ^
3 Réponses
+ 2
Try this:
public static double circleArea (double r){
double area = 0;
if (r>=0){
area = Math.PI *Math.pow(r , 2.0);
}
return area;
}
or this:
public static double circleArea (double r){
if (r>=0){
return Math.PI *Math.pow(r , 2.0);
}
return 0;
}
Your area variable has scope within the {} brackets which is why you have a problem compiling the return area; which is after the closing }.
0
Oh~ I got it, thank you so much 😆
0
What was the parameter you gave?