Write an if-else statement to describe an object. Print "Balloon" if isBalloon is true and isRed is false. Print "Red balloon" if isBalloon and isRed are both true. Print "Not a balloon" otherwise. End with newline. (Notes)

Respuesta :

The correct answer is

if (isBalloon == true && isRed == false) {

  print ("Balloon")

}

elif (isBalloon == true && isRed == true) {

  print ("Red Balloon")

}

else {

  print ("Not a balloon")

}

In this specific type of code the right thing is to use two variables and logical operator. In this sense the two conditions are true and the if-else ladder statement is used.

Answer:

if (isBalloon && isRed) {

       System.out.println("Red balloon");

    }

    else if (isBalloon) {

       System.out.println("Balloon");

    }

    else {

       System.out.println("Not a balloon");

    }

Explanation:

Ver imagen DarthVaderBarbie