1

Bellow is part of a code I'm making that calculates volumes. I'm getting the "' ) ' expected error" 2 times. First on -> if (solidom.equalsIgnoreCase("esfera"){ , and the second one at -> if (solidom.equalsIgnoreCase("cilindro") { . Can someone help me? :/

private static double volume(String solidom, double alturam, double areaBasem, double raiom) {
double vol;

    if (solidom.equalsIgnoreCase("esfera"){
        vol=(4.0/3)*Math.pi*Math.pow(raiom,3);
    }
    else {
        if (solidom.equalsIgnoreCase("cilindro") {
            vol=Math.pi*Math.pow(raiom,2)*alturam;
        }
        else {
            vol=(1.0/3)*Math.pi*Math.pow(raiom,2)*alturam;
        }
    }
    return vol;
}

3 Answers 3

3
if (solidom.equalsIgnoreCase("esfera")

should be:

if (solidom.equalsIgnoreCase("esfera"))

You have right closing parenthesis missing in your if conditions.

PS: You should really be using an IDE like Eclipse to write your code which will help you immensely to overcome these simple syntax errors.

Sign up to request clarification or add additional context in comments.

2 Comments

You're welcome. As I noted above, using an IDE like Eclipse to write your code which will really help you.
I'm using NetBeans because that's what the professor recommends to use at the University. But I'm going to install it right now. Thanks again for the tip.
3
if (solidom.equalsIgnoreCase("esfera"){

You missed parenthesis:

if (solidom.equalsIgnoreCase("esfera")){

Same for

if (solidom.equalsIgnoreCase("cilindro") {

It should be

if (solidom.equalsIgnoreCase("cilindro")) {

1 Comment

Thanks! Really fast answer :)
0

you are missing the closed parenthesis at the end of the condition of the if statement on both of these lines.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.