Answer to Question #250265 in C++ for Iman

Question #250265

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, please enter a valid one.


Enter Code: 100

Sweet ‘n Ripe Grapes 125.35

Quantity -3

Invalid Quantity, please enter again.

Quantity 2

Subtotal: 250.70


Enter Code: 101

Crunchy Apples 52.20

Quantity 1

Subtotal: 52.20


Enter Code: 0

Total Amount Due: 302.90

Cash: 100.00

Insufficient Cash!

Cash: 1000.00

Change: 697.10


=========== CHANGE BREAKDOWN ===========

1000 0 0

500 1 500.00

200 0 0

100 1 100.00

50 1 50.00

20 2 40.00

10 0 0

5 1 5.00

1 2 2.00

0.25 0 0

0.10 1 0.10

0.05 0 0


Do you want another transaction? <y/n> No.


1
Expert's answer
2021-10-13T00:29:27-0400
#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;
}


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