Answer to Question #261514 in C++ for saliha

Question #261514

Using switch-case statements only, write a C++ program that displays the following menu for

the food items available to take orders from the customer: (10 marks)

● Burgers

● Pizzas

● Sandwiches

When the user selects one of the options, a further submenu is displayed according to the chosen option.

The online food shop offers Crispy Chicken Burger (600 Rs.), Beef Burger (650 Rs.), and Fish Burger (700

Rs.) in the Burger category; Chicken tikka, Chicken Fajita and Four Seasons in the Pizza category; whereas

Club (300 Rs.), Chicken (325 Rs.), and Vegetables (315 Rs.) in the Sandwiches category. Prices of each food

item is also displayed to the user in the selected sub menu. The user will select the food item and quantity

of the item. In case of the Pizza items, the user can also select the size of pizzas (i.e. Small (850 Rs.),Medium (1200 Rs.), and Large (1600 Rs.)). The program outputs the total charges according to the chosen

options.


1
Expert's answer
2021-11-07T01:57:30-0400


#include <iostream>


using namespace std;


int main()
{
    cout<<"\nChoose an option: ";
    cout<<"\n1. Burgers\n2. Pizzas\n3. Sandwiches\n";
    int c;
    cin>>c;
    double price;
    switch(c){
        case 1:
            int c2;
            cout<<"\nChoose an option:";
            cout<<"\n1. Crispy Chicken Burger (600 Rs.):";
            cout<<"\n2. Beef Burger (650 Rs.):";
            cout<<"\n3. Fish Burger (700 Rs.):\n";
            cin>>c2;
            int n;
            cout<<"\nEnter number of items: ";
            cin>>n;
            switch(c2){
                case 1:
                    price=600*n;
                    break;
                case 2:
                    price=650*n;
                    break;
                case 3:
                    price=700*n;
                    break;
                default:
                    cout<<"\nInvalid choice";
            }
            break;
        case 2:
            int c3;
            cout<<"\nChoose an option: ";
            cout<<"\n1. Chicken tikka \n2. Chicken Fajita \n3. Four Seasons\n";
            cin>>c3;
            int n1;
            cout<<"\nEnter number of items: ";
            cin>>n1;
            switch(c3){
                case 1:
                    price=850*n1;
                    break;
                case 2:
                    price=1200*n1;
                    break;
                case 3:
                    price=1600*n1;
                    break;
                default:
                    cout<<"\nInvalid choice";
            }
            break;
        case 3:
            int c4;
            cout<<"\nChoose an option: ";
            cout<<"\n1. Club (300 Rs.) \n2. Chicken (325 Rs.) \n3. Vegetables (315 Rs.)\n";
            cin>>c4;
            int n2;
            cout<<"\nEnter number of items: ";
            cin>>n2;
            switch(c4){
                case 1:
                    price=300*n2;
                    break;
                case 2:
                    price=325*n2;
                    break;
                case 3:
                    price=315*n2;
                    break;
                default:
                    cout<<"\nInvalid choice";
            }
            break;
        default:
            cout<<"\nInvalid choice";
    }
    cout<<"\nTotal Price: "<<price;
    return 0;
}

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

Dawit yayeh
02.02.23, 16:00

It is very good answer for me thanks all about give me answer

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS