75.3k views
0 votes
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.

User Filimonov
by
6.5k points

2 Answers

1 vote

Answer: In Java

if (isBalloon && !isRed) {

System.out.println("Balloon");

}

else if (isBalloon && isRed) {

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

}

else {

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

}

User Kalyan Solasa
by
7.1k points
7 votes
Try this:
#include <iostream>
using yourname std;
int main() bool isRed = false;
bool isBalloon = false;
//Solution below
return 0; }
User Simba
by
6.8k points