Advertisement
desislava_topuzakova

Untitled

Feb 18th, 2023
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. string city; //"Bansko", "Borovets", "Varna" или "Burgas"
  7. cin >> city;
  8.  
  9. string packet; //"noEquipment", "withEquipment", "noBreakfast" или "withBreakfast"
  10. cin >> packet;
  11.  
  12. string vipDiscount;
  13. cin >> vipDiscount;
  14.  
  15. int days;
  16. cin >> days;
  17. //проверка за дните
  18. if (days < 1)
  19. {
  20. cout << "Days must be positive number!";
  21. return 0;
  22. }
  23.  
  24.  
  25. double pricePerDay = 0;
  26.  
  27. if (city == "Borovets" || city == "Bansko")
  28. {
  29. //първоначална цена за 1 ден
  30. if (packet == "withEquipment")
  31. {
  32. pricePerDay = 100;
  33. if (vipDiscount == "yes")
  34. {
  35. //10% отстъпка
  36. pricePerDay = 90;
  37. }
  38. }
  39. else if (packet == "noEquipment")
  40. {
  41. pricePerDay = 80;
  42. if (vipDiscount == "yes")
  43. {
  44. //80 - 5% остъпка = 76
  45. pricePerDay = 76;
  46. }
  47. }
  48. else
  49. {
  50. cout << "Invalid input!";
  51. return 0;
  52. }
  53. }
  54. else if (city == "Burgas" || city == "Varna")
  55. {
  56. if (packet == "withBreakfast")
  57. {
  58. pricePerDay = 130;
  59. if (vipDiscount == "yes")
  60. {
  61. pricePerDay = 114.40;
  62. //pricePerDay = 130 - 0.12 * 120;
  63. }
  64. }
  65. else if (packet == "noBreakfast")
  66. {
  67. pricePerDay = 100;
  68. if (vipDiscount == "yes")
  69. {
  70. pricePerDay = 93;
  71. //pricePerDay = pricePerDay - 0.07 * pricePerDay;
  72. }
  73. }
  74. else
  75. {
  76. cout << "Invalid input!";
  77. return 0;
  78. }
  79. }
  80. else
  81. {
  82. cout << "Invalid input!";
  83. return 0;
  84. }
  85.  
  86. //знаем колко е цената за един ден
  87. //обща цена за почивката = брой на дните * цена за 1 ден
  88. //над 7 дни -> 1 ден безплатен
  89.  
  90. if (days > 7)
  91. {
  92. days -= 1;
  93. }
  94.  
  95. double totalTripPrice = days * pricePerDay;
  96.  
  97. cout.setf(ios::fixed);
  98. cout.precision(2);
  99. cout << "The price is " << totalTripPrice << "lv! Have a nice time!";
  100.  
  101.  
  102.  
  103. }
  104.  
  105.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement