In: Computer Science
Write a program in C++ coding that utilizes a DO-WHILE loop to redisplay a menu to the user.
Ask the user to input their favorite SuperHero and display a positive or funny comment about the chosen SuperHero. If RBG is chosen, display "You can't spell TRUTH without RUTH."
Utilize a Do-While Loop to redisplay the menu to the user after item 1, 2 or 3 is executed. If item 4 is chosen, end the program.
If the user chooses 4, end the program.
1. Superman (or a SuperHero of your Choice)
2. Batman (or a Superhero of your choice)
3. The Notorious RBG (non-negotiable, RBG must be a menu choice)
4. Quit
Code :
#include <iostream>
using namespace std;
int main()
{
int selection;
do
{
cout<<"\n Menu (Enter 1,2 or 3 to select and 4 to
quit)"<<"\n";
cout<<"\n 1: Super Man";
cout<<"\n 2: Bat Man";
cout<<"\n 3: The Notorious RBG";
cout<<"\n 4: Quit";
cout<<"\n\n Enter selection: ";
cin>>selection;
if(selection == 1){
cout<<" Superman is Super. \n";
}
if(selection == 2){
cout<<" Batman is not Bat. \n";
}
if(selection == 3){
cout<<" You can't spell TRUTH without RUTH. \n";
}
}while(selection != 4);
return 0;
}
Code Screenshot :
Output screenshot :