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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
#include<iostream>
#include<iomanip>
#include<string>
void cart();
void checkout(int c, int q);
void items_display();
float item_price[13]={0,4.05, 10.00, 765.00, 399.00, 499.00, 19.99, 19.99, 69.99, 89.60, 155.00, 16.99, 26.99};
std::string item_name[12]={"The Adventure of Huckleberry Finn", "The Scarlet Letter", "Apple iPhone 6", "PlayStation 4 Console", "Xbox One Console", "Wilson NFL MVP Football", "Wilson Tennis Racket", "Nike 5.0 Men's Running Shoes", "Calvin Klein Women's Fit Dress", "Velvet by Graham & Spencer Men's Hoodie", "LEGO Movie 70800 Getaway Glider", "Disney Princess Elsa Doll"};
int item_added[13]={0,0,0,0,0,0,0,0,0,0,0,0,0};
int main()
{ std::cout<<"*****Welcome to istore!*****\n\n\n";
int choice, i=1;
do
{
std::cout << "=====Main Menu=====" <<std::endl;
std::cout << "\n\nChoose operation you want to perform.\n";
std::cout<< "1) View Your Cart";
std::cout << "2) Go Shopping";
std::cout << "3) Exit";
std::cout << "Enter your choice: ";
std::cin >> choice;
switch(choice)
{
case 1:
cart();
break;
case 2:
items_display();
break;
case 3:
i=0;
break;
default:
std::cout<<"Invalid input! Please enter 1, 2 or 3."<<std::endl;
break;
}
}
while (i==1);
return 0;
}
void items_display()
{
int choice2, quantity, choice3;
enum items{Books=1, ELectronics, Sports, Clothing, Toys};
int category;
std::cout<<"=====Categories====="<<std::endl;
std::cout<<"\n\n1) Books/n2) Electronics\n3) Sports & Outdoors\n4) Clothing & Shoes\n5) Toys"<<std::endl;
std::cout<<"Enter your choice: ";
std::cin>>category;
std::cout<<"--------------------"<<std::endl;
std::cout<<"Items Price"<<std::endl;
if(category==1)
{ std::cout<<"1) The Adventure of Huckleberry Finn "<<"$4.05"<<std::endl;
std::cout<<"2) The Scarlet Letter "<<"$10.00"<<std::endl;}
if(category==2)
{ std::cout<<"3) Apple iPhone 6 "<<"$765.00"<<std::endl;
std::cout<<"4) PlayStation 4 Console "<<"$399.00"<<std::endl;
std::cout<<"5) Xbox One Console "<<"$499.00"<<std::endl;}
if(category==3)
{ std::cout<<"6) Wilson NFL MVP Football "<<"$19.99"<<std::endl;
std::cout<<"7) Wilson Tennis Racket "<<"$17.99"<<std::endl;}
if(category==4)
{ std::cout<<"8) Nike 5.0 Men's Running Shoes "<<"$69.99"<<std::endl;
std::cout<<"9) Calvin Klein Women's Fit Dress "<<"$89.60"<<std::endl;
std::cout<<"10) Velvet by Graham & Spencer Men's Hoodie "<<"$155.00"<<std::endl;}
if(category==5)
{ std::cout<<"11) LEGO Movie 70800 Getaway Glider "<<"$16.99"<<std::endl;
std::cout<<"12) Disney Princess Elsa Doll "<<"$26.99"<<std::endl;}
std::cout<<"\nEnter your choice: ";
std::cin>>choice2;
std::cout<<"Enter the quantity: ";
std::cin>>quantity;
std::cout<<"1) Add to cart"<<std::endl;
std::cout<<"2) Prooceed to checkout"<<std::endl;
std::cout<<"What would you like to do?";
std::cin>>choice3;
if(choice3==1)
{ item_added[choice2]=item_added[choice2]+quantity;}
else
{checkout(choice2, quantity);}
}
void cart()
{
float total_price=0;
int choice4, item_edit, choice5, changed_quantity, k=0;
int cancel_c=0, cancel_q=0;
std::cout<<"=====Shopping Cart=====\n\n\n";
if(item_added[1]==0&&item_added[2]==0&&item_added[3]==0&&item_added[4]==0&&item_added[5]==0&&item_added[6]==0&&item_added[7]==0&&item_added[8]==0&&item_added[9]==0&&item_added[10]==0&&item_added[11]==0&&item_added[12]==0)
{ std::cout << "Your cart is empty!";}
else
{ std::cout<<" Items Quantity Price"<<std::endl;
do
{for(int j=1; j<=12; j++)
{ if(item_added[j]>0)
{ std::cout<<j<<") "<<item_name[j]<<std::setw(4)<<item_added[j]<<std::setw(4)<<"$"<<std::setprecision(4)<<item_price[j]*item_added[j];}
total_price+=(item_price[j]*item_added[j]);
}
std::cout<<"--------------------";
std::cout<<"Total: "<<total_price;
std::cout<<"/n1)Edit your cart"<<std::endl;
std::cout<<"2)Check out"<<std::endl;
std::cout<<"Enter your choice: ";
std::cin>>choice4;
if(choice4==1)
{ std::cout<<"Choose the item you want to edit: ";
std::cin>>item_edit;
std::cout<<"1) Remove"<<std::endl;
std::cout<<"2) change quantities"<<std::endl;
std::cout<<"Enter your choice: ";
std::cin>>choice5;
if(choice5==1)
{item_added[item_edit]=0;}
else
{std::cout<<"Enter the quantity yout want to change to: ";
std::cin>>changed_quantity;
item_added[item_edit]=changed_quantity;}
}
else
{ checkout(cancel_c, cancel_q);
k=1;}
}
while(k==1);
}
void checkout(int c, int q)
{ //functions definition is not allowed here
int choice6, choice7;
char account_number[31];
char account[31];
char bank_routing[31];
std::cout<<"=====Checkout====="<<std::endl;
if(c!=0)
{std::cout<<"Total Order: "<<"$"<<std::setprecision(4)<<item_price[c]*q<<std::endl;}
char address[41];
std::cout<<"\n\nPlease enter your address: ";
std::cin.get(address, 41);
std::cin.ignore(80,'\n');
std::cout<<"1) USPS mail\n2) UPS 2-day shipping\n3) FedEx next day"<<std::endl;
std::cout<<"Choose a shipping meethod: ";
std::cin>>choice6;
std::cout<<"1) Cash On Delivery(COD)\n2) Debit/ATM\n3) Credit\n4) eCheck\n5) PayPal\n6) ApplePay"<<std::endl;
std::cout<<"Choose a payment method: ";
std::cin>>choice7;
if(choice7==1)
{std::cout<<"Don't forget to have a Cashier’s Check available when the delivery is made!"<<std::endl;
if(choice7==2||choice7==3||choice7==5)
{ std::cout<<"please type in your account number:"<<std::endl;
std::cin.get(account_number, 31);
std::cin.ignore(80, '\n');
}
if(choice7==4)
{ std::cout<<"Please type in your account:"<<std::endl;
std::cin.get(account, 31);
std::cin.ignore(80, '\n');
std::cout<<"Please type in your bank routing number:"<<std::endl;
std::cin.get(bank_routing, 31);
std::cin.ignore(80, '\n');
}
if(choice7==6)
{ std::cout<<"Please touch the fingerprint sensor."<<std::endl;
}
std::cout<<"Thank you for the business!"<<std::endl;
} //expected ";" at end of declaration
//expected'}'
|