Answer to Question #214353 in C++ for meyla

Question #214353

CODE MEAL NAME PRICE (RM)

1 Chicken Fillet 15.00

2 Roasted Beef 20.00

3 Rib eye Fillet 30.00

CODE BEVERAGE NAME PRICE (RM)

S Syrup 1.50

L Lychee 2.80

C Coconut 3.50

i. The customer order the meal and beverage based on the code

ii. system will ask the quantity for each order

iii. displays the quantity and the total price of the meal

iv. displays the quantity and the total price of the beverage

v. displays the total price that the user needs to pay

vi. The system will repeat the process i to v until user put ‘N’ to stop the program


SAMPLE OUTPUT : 


CODE  MEAL NAME   PRICE(RM)


1   Chicken fillet  15.00

2   Roasted Beef  20.00

3   Rib eye fillet   30.00

Enter your meal code: 2

Enter quantity for the meal: 5




1
Expert's answer
2021-07-06T12:17:06-0400
#include <iostream>


using namespace std;
int gettotal(float m,int q){
    return (m*q);
}
int main()
{
    int total=0;
    while(true){
        
        cout<<"1   Chicken fillet  15.00 \n2   Roasted Beef  20.00 \n3   Rib eye fillet   30.00\n";
        int ch; 
        cout<<"\nEnter your meal code:";
        cin>>ch;
        int quantity;
        cout<<"\nEnter quantity for the meal:";
        cin>>quantity;
        if (ch==1){
            total=total+gettotal(15.00,quantity);
        }
        else if (ch==2){
            total=total+gettotal(20.00,quantity);
        }
        else if (ch==3){
            total=total+gettotal(30.00,quantity);
        }
        
        cout<<"\ntotal: "<<total<<endl;
        string ch2;
        cout<<"\nContinue?";
        cin>>ch2;
        if (ch2=="N")
            break;
    }
    
    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

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS