Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- using namespace std;
- int main(){
- int quantity,counter,product_choice,payment_option,time,i;
- double product_cost,delivery_charge,discount,surcharge,final_cost,card_cost;
- string username,password,date,loyalty,card_choice,choice;
- string product[499]={"Wireless Earphones","iPhone 11","USB Type C charging cable","iPhone Case","Sony PS4","Microsoft Surface Go","Logitech G403 Mouse","Portable Phone Tripod","CCTV Camera","HP Inkjet Printer","HP Original Ink Cartridge x4","Waterproof Outdoor Sleeping Bag","Multipurpose Hiking Backpack","Foldable Treadmill Running Machine","Stationary Exercise Bike","Dove Body Wash","Head & Shoulders Shampoo","LED Wall Clock","Elba Pressure Cooker","Thermos 1.0L","Electronic Kitchen Scale","10pcs Dish Cloth Towel","Non-stick Frying Pan"};
- const int price[499]={35.00,3599.00,12.50,10.00,1449.00,2899.00,168.99,14.99,115.00,189.00,25.00,18.90,59.99,669.00,124.50,20.00,15.90,24.90,230.00,31.00,12.50,11.99,89.00};
- cout<<"Welcome to Lapeeza, here are the products we have,\n";
- for (i=0;i<23;i++){
- cout<<i+1<<". "<<product[i]<<" - RM"<<price[i]<<endl;
- }
- cout<<endl;
- do{
- cout<<"Which product would you like to buy? Use the number of the product to choose : ";
- cin>>product_choice;
- while(product_choice>23||product_choice<1){
- cout<<"Please make a valid choice : ";
- cin>>product_choice;
- }
- cout<<"How many units would you like? : ";
- cin>>quantity;
- counter=counter+quantity;
- product_cost=price[product_choice-1]*quantity;
- final_cost=final_cost+product_cost;
- cout<<"Would you like to buy another product?(y/n) : ";
- cin>>choice;
- } while (choice=="Y"||choice=="y");
- if (counter<6&&counter>0){
- delivery_charge=5;
- }
- else if (counter>5&&counter<11){
- delivery_charge=6;
- }
- else if (counter>10&&counter<16){
- delivery_charge=6.50;
- }
- else {
- delivery_charge=0;
- }
- cout<<"\n4 payment options are available on Lapeeza.\n";
- do{
- cout<<"\n1) Cash on delivery (2% charge applies)\n";
- cout<<"2) Credit or debit card (2% charge applies)\n";
- cout<<"3) Lapeeza wallet (enjoy 5% discount on all products)\n";
- cout<<"4) Online banking\n";
- cout<<"Please choose a payment option : ";
- cin>>payment_option;
- } while (payment_option>4||payment_option<1);
- if (payment_option==1||payment_option==2){
- surcharge=0.02;
- }
- else if (payment_option=3){
- discount=0.05;
- }
- cout<<"\nAlright, we just need a few more details to calculate your final cost.\n";
- cout<<"Please enter your username : ";
- cin>>username;
- cout<<"Please enter your password : ";
- cin>>password;
- cout<<"You are now logged in. \n";
- cout<<"Do you own a loyalty card or have spent at least RM5 on Lapeeza for three days straight?(y/n) : ";
- cin>>loyalty;
- if (loyalty!="y"&&loyalty!="Y"&&loyalty!="n"&&loyalty!="N"){
- cout<<"Please enter a valid option (y/n) : ";
- cin>>loyalty;
- }
- if (loyalty=="n"||loyalty=="N"){
- cout<<"Do you want to purchase a loyalty card for RM10 to enjoy a 10% cash rebate for your purchases? (y/n) : ";
- cin>>card_choice;
- if (card_choice=="y"||card_choice=="Y"){
- card_cost=10;
- }
- }
- if (loyalty=="y"||loyalty=="Y"||card_choice=="y"||card_choice=="Y"){
- discount=discount+0.1;
- }
- cout<<"What is today's date? (dd/mm) : ";
- cin>>date;
- cout<<"What is the time? (0000~2359) : ";
- cin>>time;
- if (date.substr(0,2)=="13"){
- if (time<=200||time>=1300){
- discount=discount+0.2;
- }
- }
- final_cost=final_cost+delivery_charge+card_cost+(surcharge*final_cost)-(discount*final_cost);
- cout<<fixed<<setprecision(2)<<"\nThank you for shopping with Lapeeza!\nYour final cost is RM"<<final_cost<<".\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement