Guest User

Untitled

a guest
Feb 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. // Rifqi Rachmanda Eryawan
  2. // 001201700004
  3. #include <iostream>
  4. #include <ctime>
  5. #include <cstdlib>
  6. using namespace std;
  7. int main() {
  8. int brand, price, ans; // type anything and press enter to quit
  9. int subtotal, rate, installment, total, month, paymonth;
  10. char response; // press N to checkout
  11. char name[100];
  12. srand(time(NULL));
  13. do{
  14. cout << "Welcome to KNUCKLES HEAVY BIKE DEALER!" << endl;
  15. cout << "Input name: ";
  16. cin >> name;
  17.  
  18. cout << "\nOur motorbikes are the most expensive ones in the United States of Uganda!" << endl;
  19. cout << "Select motorbike brand: " << endl;
  20. cout << "1. Neiman Marcus Limited Edition Fighter (USD 16 000 000)" << endl;
  21. cout << "2. 1949 E90 AJS Porcupine (USD 10 000 000)" << endl;
  22. cout << "3. Ecosse ES1 Spirit (USD 6 000 000)" << endl;
  23. cout << "4. Hildebrand & Wolfmuller Bike (USD 5 500 000)" << endl;
  24. cout << "5. Gold BMS Nehmesis (USD 5 000 000)\n" << endl;
  25. cout << "Which variant you will buy? " << endl;
  26. cin >> brand;
  27.  
  28. cout << "\nYou will buy a ";
  29. switch (brand) // statement for multiple decisions
  30. {
  31. case 1:
  32. cout << "Neiman Marcus Limited Edition Fighter." << endl;
  33. break;
  34. case 2:
  35. cout << "1949 E90 AJS Porcupine." << endl;
  36. break;
  37. case 3:
  38. cout << "Ecosse ES1 Spirit." << endl;
  39. break;
  40. case 4:
  41. cout << "Hildebrand & Wolfmuller Bike." << endl;
  42. break;
  43. case 5:
  44. cout << "Gold BMS Nehmesis." << endl;
  45. break;
  46. default: // any input than the others
  47. break;
  48. }
  49. cout << "Insert number of months for installment: ";
  50. cin >> month;
  51. cout << "\nPress N to checkout." << endl;
  52. cin >> response;
  53. }
  54. while (response == 'y' || response == 'Y'); // when you press Y the program won't work properly
  55.  
  56. cout << "\n";
  57. cout << "\t================================================" << endl;
  58. cout << "\t KNUCKLES HEAVY BIKE DEALER" << endl;
  59. cout << "\t================================================" << endl;
  60. cout << "\tBuyer: " << name << endl;
  61. cout << "\tMotorbike: ";
  62. switch (brand) // statement for multiple decisions
  63. {
  64. case 1:
  65. cout << "Neiman Marcus Limited Edition Fighter" << endl;
  66. price = 16000000;
  67. break;
  68. case 2:
  69. cout << "1949 E90 AJS Porcupine" << endl;
  70. price = 10000000;
  71. break;
  72. case 3:
  73. cout << "Ecosse ES1 Spirit" << endl;
  74. price = 6000000;
  75. break;
  76. case 4:
  77. cout << "Hildebrand & Wolfmuller Bike" << endl;
  78. price = 5500000;
  79. break;
  80. case 5:
  81. cout << "Gold BMS Nehmesis" << endl;
  82. price = 5000000;
  83. break;
  84. default: // any input than the others
  85. price = 0;
  86. break;
  87. }
  88. subtotal = price / month;
  89. rate = subtotal * 0.1;
  90. installment = subtotal + rate;
  91. total = installment * month;
  92. paymonth = total / month;
  93. cout << "\tInitial price: USD " << price << endl;
  94. cout << "\tInstallment: " << month << " month(s)" << endl;
  95. cout << "\tRate: 10%" << endl;
  96. cout << "\tFinal price: USD " << total << endl;
  97.  
  98. // current date/time based on current system
  99. time_t now = time(0);
  100. // convert now to string form
  101. char* dt = ctime(&now);
  102.  
  103. cout << "\tCheckout date: " << dt << endl;
  104. cout << "\tYou must pay USD " << paymonth << " for " << month << " month(s)." << endl;
  105. cout << "\n\tYour license plate will be B "<< (rand()%9000)+1000 << " CIT when" << endl << "\tyour motorbike has come to Jakarta." << endl;
  106. cout << "\t================================================" << endl;
  107. cout << "\t MUCHAS GRACIAS!" << endl;
  108. cout << "\t================================================" << endl;
  109. cout << "\n";
  110. cout << "\tType anything and press enter to quit" << endl;
  111. cin >> ans; // type anything
  112. return 0;
  113. }
Add Comment
Please, Sign In to add comment