1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#include <iostream>
#include <string>
using namespace std;
int main ()
string name, address;
int item, quantity;
double price, total = quantity * price;
int SIZE = 6;
int VALID_ITEM [] = {106, 108, 307, 405, 457, 688};
int VALID_ITEM_PRICE [] = {0.59, 0.99, 4.50, 15.99, 17.50, 39.00};
int sub;
string foundIt = "N";
string MSG_YES = "Item available";
string MSG_NO = "Item not found";
cout << "Please enter your name: ";
cin >> name;
cout << "Please enter your address: ";
cin >> address;
cout << "Please enter the item: ";
cin >> item;
cout << "Please enter the item quantity: ";
cin >> quantity;
sub = 0
while (sub <= SIZE)
if (item = VALID_ITEM [sub])
foundIt = “Y”
price = VALID_ITEM_PRICE [sub];
sub = sub + 1
if (foundIt = “Y”)
cout << MSG_YES
<< quantity, " at $" , price, " each", /n
<< "Total: ", total;
else
cout << MSG_NO;
return 0;
|