Advertisement
Guest User

1st one

a guest
Nov 17th, 2019
1,098
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main(){
  7. int quantity,counter,product_choice,payment_option,time,i;
  8. double product_cost,delivery_charge,discount,surcharge,final_cost,card_cost;
  9. string username,password,date,loyalty,card_choice,choice;
  10. 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"};
  11. 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};
  12. cout<<"Welcome to Lapeeza, here are the products we have,\n";
  13. for (i=0;i<23;i++){
  14. cout<<i+1<<". "<<product[i]<<" - RM"<<price[i]<<endl;
  15. }
  16. cout<<endl;
  17. do{
  18. cout<<"Which product would you like to buy? Use the number of the product to choose : ";
  19. cin>>product_choice;
  20. while(product_choice>23||product_choice<1){
  21. cout<<"Please make a valid choice : ";
  22. cin>>product_choice;
  23. }
  24. cout<<"How many units would you like? : ";
  25. cin>>quantity;
  26. counter=counter+quantity;
  27. product_cost=price[product_choice-1]*quantity;
  28. final_cost=final_cost+product_cost;
  29. cout<<"Would you like to buy another product?(y/n) : ";
  30. cin>>choice;
  31. } while (choice=="Y"||choice=="y");
  32.  
  33.  
  34. if (counter<6&&counter>0){
  35. delivery_charge=5;
  36. }
  37. else if (counter>5&&counter<11){
  38. delivery_charge=6;
  39. }
  40. else if (counter>10&&counter<16){
  41. delivery_charge=6.50;
  42. }
  43. else {
  44. delivery_charge=0;
  45. }
  46.  
  47. cout<<"\n4 payment options are available on Lapeeza.\n";
  48. do{
  49. cout<<"\n1) Cash on delivery (2% charge applies)\n";
  50. cout<<"2) Credit or debit card (2% charge applies)\n";
  51. cout<<"3) Lapeeza wallet (enjoy 5% discount on all products)\n";
  52. cout<<"4) Online banking\n";
  53. cout<<"Please choose a payment option : ";
  54. cin>>payment_option;
  55. } while (payment_option>4||payment_option<1);
  56. if (payment_option==1||payment_option==2){
  57. surcharge=0.02;
  58. }
  59. else if (payment_option=3){
  60. discount=0.05;
  61. }
  62.  
  63.  
  64. cout<<"\nAlright, we just need a few more details to calculate your final cost.\n";
  65. cout<<"Please enter your username : ";
  66. cin>>username;
  67. cout<<"Please enter your password : ";
  68. cin>>password;
  69. cout<<"You are now logged in. \n";
  70. cout<<"Do you own a loyalty card or have spent at least RM5 on Lapeeza for three days straight?(y/n) : ";
  71. cin>>loyalty;
  72. if (loyalty!="y"&&loyalty!="Y"&&loyalty!="n"&&loyalty!="N"){
  73. cout<<"Please enter a valid option (y/n) : ";
  74. cin>>loyalty;
  75. }
  76. if (loyalty=="n"||loyalty=="N"){
  77. cout<<"Do you want to purchase a loyalty card for RM10 to enjoy a 10% cash rebate for your purchases? (y/n) : ";
  78. cin>>card_choice;
  79. if (card_choice=="y"||card_choice=="Y"){
  80. card_cost=10;
  81. }
  82. }
  83. if (loyalty=="y"||loyalty=="Y"||card_choice=="y"||card_choice=="Y"){
  84. discount=discount+0.1;
  85. }
  86. cout<<"What is today's date? (dd/mm) : ";
  87. cin>>date;
  88. cout<<"What is the time? (0000~2359) : ";
  89. cin>>time;
  90. if (date.substr(0,2)=="13"){
  91. if (time<=200||time>=1300){
  92. discount=discount+0.2;
  93. }
  94. }
  95. final_cost=final_cost+delivery_charge+card_cost+(surcharge*final_cost)-(discount*final_cost);
  96. cout<<fixed<<setprecision(2)<<"\nThank you for shopping with Lapeeza!\nYour final cost is RM"<<final_cost<<".\n";
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement