Answer to Question #246931 in C++ for Imman

Question #246931

Sample Run 1

Welcome to CS126 Mart!

Item Codes Description Price

100 Sweet ‘n Ripe Grapes 125.35

101 Crunchy Apples 52.20

109 Green Peas 25.75


Enter Code: 128

Invalid code. This program will exit.


Sample Run 2

Welcome to CS126 Mart!

Item Codes Description Price

100 Sweet ‘n Ripe Grapes 125.35

101 Crunchy Apples 52.20

109 Green Peas 25.75


Enter Code: 100

Sweet ‘n Ripe Grapes 125.35

Quantity -3

Invalid quantity


1
Expert's answer
2021-10-06T06:18:04-0400

Source code


#include <iostream>


using namespace std;


int main()
{
    cout<<"\nWelcome to CS126 Mart!";
    cout<<"\nItem Codes Description Price";
    cout<<"\n100 Sweet ‘n Ripe Grapes 125.35";
    cout<<"\n101 Crunchy Apples 52.20";
    cout<<"\n109 Green Peas 25.75";
    
    int code;
    cout<<"\nEnter code: ";
    cin>>code;
    if (code==100)
        cout<<"\nSweet ‘n Ripe Grapes 125.35";
    else if (code==100)
        cout<<"\nCrunchy Apples 52.20";
    else if (code==100)
        cout<<"\n109 Green Peas 25.75";
    else{
        cout<<"\nInvalid code. This program will exit.";
        exit('0');
        
    }
    int quantity;
    cout<<"\nQuantity: ";
    cin>>quantity;
    if (quantity<=0)
        cout<<"\nInvalid quantity";
    return 0;
}


Sample Output 1



Sample Output 2





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