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 46 47 48 49 50 51 52
|
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
int main()
{
int barcode[10]= {1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010};
string item[10]= {"Apples", "Yogurt", "Raisins", "Onions", "Eggs", "Peanuts", "Cereal", "Bananas", "Beer", "Bottled Water"};
double itemPrice[10]= {1.49, 1.29, 3.39, 0.79, 2.49, 5.99, 3.50, 2.55, 5.55, 1.49};
int myArray[] = {};
int a, sum;
int arrayname[]={};
int i, itemChoice, keepGoing, weight;
bool run = true;
while (run)
{
for (i=0; i<10; i++)
{
cout << "Barcode: " << barcode[i] << "-" << item[i] << " :" << itemPrice[i] << "\n";
}
cout << "What item? (pick the number)\n";
cin >> itemChoice;
if ((itemChoice==1001)|| (itemChoice==1003)||(itemChoice==1004)||(itemChoice==1006)||(itemChoice==1008))
{
cout << "How much does it weigh in pounds?\n";
cin >> weight;
}
else if ((itemChoice==1002)||(itemChoice==1005)||(itemChoice==1007)||(itemChoice==1009)||(itemChoice==1010))
{
exit;
}
else
{
cout << "Error!!!\n";
}
for (int i=0; i < 3; ++i) {
sum += itemChoice[i];
}//Want to sum up each items total each time the while loop is running.
cout << "the sum of the array elements is: " << sum << endl;
cout << "Do you want to continue?(1 to add more items and 2 to proceed to the receipt)\n";
cin >> keepGoing;
if (keepGoing==2)
{
run = false;
}
else if (keepGoing==1)
{
run = true;
}
}
return 0;
}
|