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
#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');
}
Comments
Leave a comment