Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please use c++ to answer this question thank you. Use the switch and do while st

ID: 3675385 • Letter: P

Question

please use c++ to answer this question

thank you.

Use the switch and do while statements to write a program that displays following menu: Option 1 Option 2 Option 3 Option 4 Option 5 Quit Please Enter You Choice (1-6): If the user enters a choice between the program displays message stating the option picked by the user. The menu is displayed again. If the user enters 6 as choice, the program displays "Thank you for choosing our program" and ends. If the user enters a choice other than 1-6, the program displays "Invalid choice. You need to select an option between 1 and 6". The menu is displayed asain.

Explanation / Answer

Hi below is the sample program for your reference using do while loop that prompts user to select an option by entering option number. As user selects an option, program displays some information depending upon then option selected.

#include <iostream> // library that contains basic input output functions

using namespace std;

int main()
{
int option; // user's entered option will be saved in this variable
do //do-while loop starts here.that display menu again and again until user select to exit program
{
//Displaying Options for the menu
cout << "1) Option 1 " << endl;
cout << "2) Option 2 " << endl;
cout << "3) Option 3" << endl;
cout << "4) Option 4 " << endl;

cout << "5) Option 5" << endl;

cout << "6) Option 6 " << endl;

//Prompting user to enter an option according to menu
cout << "Please select an option : ";
cin >> option; // taking option value as input and saving in variable "option"

if(option == 1) // Checking if user selected option 1
{
cout << "The user picked Option 1" << endl;
}
else if(option == 2) // Checking if user selected option 2
{
cout << "The user picked Option 2" << endl;
}
else if(option == 3) // Checking if user selected option 3
{
   cout << "The user picked Option 3" << endl;
}

else if(option == 4) // Checking if user selected option 4
{
   cout << "The user picked Option 4" << endl;
}

else if(option == 5) // Checking if user selected option 5
{
   cout << "The user picked Option 5" << endl;
}

else if(option == 6) // Checking if user selected option 6
{
cout << "Thank you for choosing our program" << endl;
}
else if //user has entered invalid choice (other than 1,2,3,4,5 or 6)
{
//Displaying error message
cout << "Invalid choice. You need to select an option between 1 and 6" << endl;
}
}
while(option != 6); //condition of do-while loop
  return 0;
}