Question

In: Computer Science

Write a program in C++ coding that utilizes a DO-WHILE loop to redisplay a menu to...

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

Solutions

Expert Solution

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 :


Related Solutions

Do the following lab by while or Do-while loop. question: Write a c++ program that asks...
Do the following lab by while or Do-while loop. question: Write a c++ program that asks students to enter 3 valid grades and then calculate the average and print it. if the user enters the invalid grade you should print the error message and get the new grade. Hint1: each time your program ask the following question: "Do you want to calculate another average?" and if the answer to this question is "Y" or "y" then you should continue. Hint2:...
Write a C program that meets the following requirements. Uses a while loop to display the...
Write a C program that meets the following requirements. Uses a while loop to display the first 10 natural numbers (on one row, with a tab separating each number) Uses a while loop to find the sum of the second set of 10 natural numbers. Reads a user entry and displays all the natural numbers up to the user entry (on a column list with a new line separating each number). Finds and displays the sum of all natural numbers...
Write a Java program that uses a while loop to do the following: Repeatedly asks the...
Write a Java program that uses a while loop to do the following: Repeatedly asks the user to enter a number or -1 to exit the program. Keeps track of the smallest and largest numbers entered so far: You will need a variable for the smallest number and another variable for the largest number. Read the first number the user enters, and if it is not -1 set the smallest and largest variables to that number. Use a loop to...
write a program bus management system? using: if else, for loop, do while loop, function, arrays,...
write a program bus management system? using: if else, for loop, do while loop, function, arrays, string, structure
Modify the previous program to use the Do-While Loop instead of the While Loop. This version...
Modify the previous program to use the Do-While Loop instead of the While Loop. This version of the program will ask the user if they wish to enter another name and accept a Y or N answer. Remove the "exit" requirement from before. Output: Enter the full name of a person that can serve as a reference: [user types: Bob Smith] Bob Smith is reference #1 Would you like to enter another name (Y or N)? [user types: y] Enter...
write an operational semantic for a while loop in c++
write an operational semantic for a while loop in c++
C++ while loop Exercise Write a program that continues to ask the user to enter any...
C++ while loop Exercise Write a program that continues to ask the user to enter any set of numbers, until the user enters the number -1. Then display the total sum of numbers entered and their average. (note that you need to define a counter that counts how many numbers so the average = (sum/n) where n is your counter total. #include <iostream> using namespace std; int main() { int number, n=0, sum=0; cout << "Enter a number to start...
Write a program in java that deliberately contains an endless or infinite while loop. The loop...
Write a program in java that deliberately contains an endless or infinite while loop. The loop should generate multiplication questions with single-digit random integers. Users can answer the questions and get immediate feedback. After each question, the user should be able to stop the questions and get an overall result. See Example Output. Example Output What is 7 * 6 ? 42 Correct. Nice work! Want more questions y or n ? y What is 8 * 5 ? 40...
Problem: Construct a C program that will make use of user-defined functions, the do/while loop, the...
Problem: Construct a C program that will make use of user-defined functions, the do/while loop, the for loop, and selection. Using a do/while loop, your program will ask/prompt the user to enter in a positive value representing the number of values they wish to have processed by the program or a value to quit/exit. If the user enters a 0 or a negative number the program should exit with a message to the user indicating they chose to exit. If...
C++ Write a menu based program for the pet rescue. There should be 2 menu options...
C++ Write a menu based program for the pet rescue. There should be 2 menu options -Add a pet -View pets -If the user chooses option 1, you will open a data file for writing without erasing the current contents, and write a new pet record to it. The file can be formatted any way that you choose but should include the pet's name, species, breed, and color. You my also include any additional information you think is appropriate. -If...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT