Answer to Question #99425 in C++ for Caleb

Question #99425
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.
#include <iostream>
using namespace std;

int main() {
bool isRed;
bool isBalloon;

cin >> isRed;
cin >> isBalloon;

/* Your solution goes here */

return 0;
}
1
Expert's answer
2019-12-01T13:18:31-0500
#include <iostream>

using namespace std;
int main() {
  bool isRed;
  bool isBalloon;
  cin >> isRed;
  cin >> isBalloon;
   
  if(isBalloon && !isRed) {
    cout<<"Balloon" << endl;
  }
  else if (isBalloon && isRed) {
    cout<<"Red balloon" << endl;
  }
  else {
    cout<<"Not a balloon" << endl;
  }
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS