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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
#include<iostream>
using namespace std;
int main(){
int code[10] = {1,2,3,4,5,6,7,8,9,10};
char prod[10][30]= {"Apple","Banana","Orange","Berry","Grape","Peach","Pear","Lemon","Cherry","Apricot"};
int price[10] = {15,25,35,45,55,65,75,85,95,105};
int stock[10] = {10,10,10,10,10,10,10,10,10,10};
int total;
int k = 0;
int ans;
int m = 1;
int item;
do{
cout<<"============ Ilao Fruit Store ============\n\t\t Welcome!\n We restock every transaction!\n\n1) Order \n2) Pay \n3) Exit\n\n";
int choice;
cout<<"Choice: ";
cin>>choice;
cout<<endl;
if(choice == 1){
do{
cout<<"\nCode\t\tProduct\t\tPrice\t\tStock\n\n";
for (int i = 0; i < 10; i++){
cout<<code[i]<<"\t\t"<<prod[i]<<"\t\t"<<price[i]<<"\t\t"<<stock[i]<<"\n"<<endl;
}
cout<<"E1: What's your order?"<<endl;
cout<<"Order #: "<<m<<endl;
cout<<"(Please enter Item Code then Fruit)"<<endl;
cout<<"C1: ";
char prod[10];
cin>>k;
cout<<"C1: ";
cin>>prod;
cout<<"E1: How many?"<<endl;
cout<<"C1: ";
cin>>item;
if(item>10||item<=0){
cout<<"Invalid Transaction!!!"<<endl;
cout<<"Goodbye! Please Shop again!";
break;
}
cout<<"E1: Do you want to still order?\n1 for YES\n2 for NO"<<endl;
cout<<"C1: ";
cin>>ans;
cout<<endl;
cout<<endl;
if(ans==1){
m++;
continue;
}else if(ans==2){
break;
}
}while(1);
k = k - 1;
total = price[k] * item;
for(int j = 0; j < m; j++){
cout<<"Order #: "<<m<<"\t\t"<<prod[k]<<" "<<item<<" = "<<total<<endl;
}
cout<<endl;
stock[k] = stock[k] - item;
}
else if(choice == 2){
cout<<"Balance: "<<total<<endl;
cout<<"Payment: ";
int payment;
cin>>payment;
cout<<"Change: "<<payment - total<<endl;
}
else if(choice == 3){
cout<<"Thank you for shopping!";
break;
}else{
cout<<"Invalid Input!!!";
}
cout<<endl;
}while(1);
}
|