Answer to Question #309979 in C++ for Nikhil

Question #309979

Write a program in such a way that if I'm going to enter a random number from 1 to 5, and I get the food item and its price on separate lines (use '\n'). 1. Pizza, Rs 239 2. Burger, Rs 129 3. Pasta, Rs 179 4. French Fries, Rs 99 5. Sandwich, Rs 149 So, in this case if I enter 3, the output should print something like - Food item - Pasta Price - Rs 179

1
Expert's answer
2022-03-11T14:04:08-0500
#include <iostream>

using namespace std;

void Menu()
{
	cout << "\nPlease, enter a random number from 1 to 5: ";
	cout << "\n1. Pizza, Rs 239"
		<< "\n2. Burger, Rs 129"
		<< "\n3. Pasta, Rs 179"
		<< "\n4. French Fries, Rs 99"
		<< "\n5. Sandwich, Rs 149"
		<< "\n6. Exit";
		
}

int main()
{
	char choice;
	Menu();
	do
	{	
		cout << "\nSelect choice:";
		cin >> choice;
		switch (choice)
		{
			case '1':
			{
				cout << "Food item - Pizza, Rs 239";
				break;
			}
			case '2':
			{
				cout << "Food item - Burger, Rs 129";
				break;
			}
			case '3':
			{
				cout << "Food item - Pasta, Rs 179";
				break;
			}
			case '4':
			{
				cout << "Food item - French Fries, Rs 99";
				break;
			}
			case '5':
			{
				cout << "Food item - Sandwich, Rs 149";
				break;
			}
		}
	} while (choice!='6');
}

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