In: Computer Science
Create a program that will ask the user to choose their order from a simple menu. Customers first choose from three types of dishes: Sandwiches/wraps, Rice Meals, or Noodles. They can type in 1, 2, or 3 to select the type then, they choose a specific dish as shown below. Confirm their order by displaying it on the screen after they make their selection. 1. Sandwiches/wraps Hamburger Chicken shawarma 2. Rice meals Arroz con pollo Chana masala 3. Noodles Chow mein Pasta al pomodoro Which variation of the if statement would best fit the requirements (if, if-else, if-else-if chain, nested if)? Create the complete C++ program.
Thanks for the question.
Below is the code you will be needing Let me know if you have
any doubts or if you need anything to change.
Thank You !!
The best fit for the requirement is using if else statement as illustrated in the code.
===========================================================================
#include <iostream>
using namespace std;
int main(){
int userChoice=0;
cout<<"Type [1] for
Sandwiches/Wraps"<<endl
<<"Type [2] for Rice
Meals"<<endl
<<"Type [3] for
Noodles"<<endl
<<"Enter your choice here:
";
cin>>userChoice;
if(userChoice==1){
cout<<"Order confirmed. Your order: Sandwiches/wraps
Hamburger Chicken shawarma ";
cout<<endl;
}else if(userChoice==2){
cout<<"Order confirmed. Your order: Rice meals Arroz con
pollo Chana masala ";
cout<<endl;
}else if(userChoice==3){
cout<<"Order confirmed. Your order: Noodles Chow mein Pasta
al pomodoro ";
cout<<endl;
}else{
cout<<"Sorry! Your selection is invalid"<<endl;
}
}
thank you so much. Please do give a thumbs up : )