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
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
Comments
Leave a comment