Advertisement
desislava_topuzakova

02. Safari

Feb 18th, 2023
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  
  7. double budget;
  8. cin >> budget;
  9.  
  10. double needLiters;
  11. cin >> needLiters;
  12.  
  13. string dayOfWeek; //"Saturday" и "Sunday"
  14. cin >> dayOfWeek; //въвеждане на текст без интервали
  15.  
  16. //цена за сафари = цена гориво + цена за екскурзовод (100)
  17. double safariPrice = (needLiters * 2.10) + 100;
  18.  
  19. //отстъпки
  20. //20% от цената ако е неделя
  21. if (dayOfWeek == "Sunday")
  22. {
  23. safariPrice = safariPrice - 0.2 * safariPrice;
  24. //safariPrice = 0.8 * safariPrice;
  25. //safariPrice *= 0.8;
  26. }
  27. //10% от цената ако е събота
  28. else if (dayOfWeek == "Saturday")
  29. {
  30. safariPrice = safariPrice - 0.10 * safariPrice;
  31. //safariPrice = 0.9 * safariPrice;
  32. //safariPrice *= 0.9;
  33. }
  34.  
  35. cout.setf(ios::fixed);
  36. cout.precision(2);
  37.  
  38.  
  39. //крайна цена за сафарито
  40. //бюджетът е достатъчен
  41. if (budget >= safariPrice)
  42. {
  43. cout << "Safari time! Money left: " << budget - safariPrice << " lv. ";
  44. }
  45. else //budget < safariPrice
  46. {
  47. //бюджетът не е достатъчен
  48. cout << "Not enough money! Money needed: " << safariPrice - budget << " lv.";
  49. }
  50.  
  51.  
  52.  
  53. }
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement