Advertisement
SimeonTs

SUPyF2 P.-Mid-Exam/10 March 2019/1 - 01. Spring Vacation Tri

Oct 29th, 2019
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.56 KB | None | 0 0
  1. """
  2. Technology Fundamentals Mid Exam - 10 March 2019 Group 1
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1494#0
  4.  
  5. SUPyF2 P.-Mid-Exam/10 March 2019/1 - 01. Spring Vacation Trip
  6.  
  7. Problem:
  8. A group of friends decide to go to a trip for a few days during spring vacation.
  9. They have a certain budget. Your task is to calculate their expenses during the trip and find out if they are going
  10. to have enough money to finish the vacation.
  11. Create a program that calculates travelling expenses by entering the following information:
  12. -   Days of the vacation
  13. -   Budget - its for the whole group
  14. -   The count of people
  15. -   Fuel per kilometer – the price for fuel that their car consumes per kilometer
  16. -   Food expenses per person
  17. -   Hotel room price for one night – again, for one person
  18. If the group is bigger than 10, they receive a 25% discount from the total hotel expenses.
  19. Every day, they travel some distance and you have to calculate the expenses for the travelled kilometers.
  20. Every third and fifth day, they have some additional expenses, which are 40% of the current value of the expenses.
  21. Every seventh day, their expenses are reduced, because they withdraw (receive) a small amount of money –
  22. you can calculate it by dividing the amount of the current expenses by the group of people.
  23. If the expenses exceed the budget at some point, stop calculating and print the following message:
  24. "Not enough money to continue the trip"
  25. If the budget is enough:
  26. "You have reached the destination. You have {money}$ budget left."
  27. Print the result formatted 2 digits after the decimal separator.
  28. Input / Constraints
  29. • On the 1st line, you are going to receive the days of the trip – an integer in the range [1…100]
  30. • On the 2nd line – the budget – a real number in the range [0.00 – 1000000.00]
  31. • On the 3rd line - the group of people – an integer in the rang [1 - 50]
  32. • On the 4th line – the price for fuel per kilometer – a real number [0.00 – 20.00]
  33. • On the 5th line – food expenses per person for a day – a real number [0.00 – 50.00]
  34. • On the 6th line – the price for a room for one night per person – a real number [0.00 – 1000.00]
  35. • On the next n lines – one for each of the days – the travelled distance in kilometers per day–
  36. a real number in the range [0.00 - 1000]
  37. Output
  38. • "Not enough money to continue the trip. You need {money}$ more." –
  39. if the budget is not enough
  40. • "You have reached the destination. You have {money}$ budget left." – if it’s enough.
  41. Print the result formatted 2 digits after the decimal separator.
  42. Examples:
  43. Input:
  44. 7
  45. 12000
  46. 5
  47. 1.5
  48. 10
  49. 20
  50. 512
  51. 318
  52. 202
  53. 154
  54. 222
  55. 108
  56. 123
  57.  
  58. Output:
  59. You have reached the destination. You have 5083.48$ budget left.
  60.  
  61. Comments:
  62. We receive the days of the vacation, the budget, the group, the consumed fuel per kilometer,
  63. the food expenses and the price for a hotel room for one night. We must calclate the food expenses: 10 * 5 * 7 = 350
  64. And the price for the hotel for all of the nights:
  65. 20 * 5 * 7 = 700
  66. The curent expenses are 1050. For each day, we have to calculate the consumed fuel – {travelledDistance} * 1.5
  67. On every 3rd  and 5th  day we add the additional expenses:
  68. 0.4 * {currentExpenses}
  69. On every 7th day, they receive some money:
  70. {currentExpense} / {groupOfPeople}
  71. After we have added the fuel expenses for each day and made the other calculations,
  72. the expenses have reached 8645.652. When we divide them by the group (5), the result is 1729.1304,
  73. so we have to reduce the expenses by that sum. The expenses become 6916.5216. The budget is enough, so the result is:
  74. "You have reached the destination. You have 5083.48$ budget left."
  75.  
  76. Input:
  77. 10
  78. 20500
  79. 11
  80. 1.2
  81. 8
  82. 13
  83. 100
  84. 150
  85. 500
  86. 400
  87. 600
  88. 130
  89. 300
  90. 350
  91. 200
  92. 300
  93.  
  94. Output:
  95. Not enough money to continue the trip. You need 465.79$ more.
  96. """
  97. days = int(input())
  98. budget = float(input())
  99. people = int(input())
  100. price_km = float(input())
  101.  
  102. food_price = float(input()) * people * days
  103. hotel_price = float(input()) * people * days
  104.  
  105. if people > 10:
  106.     hotel_price -= hotel_price * 0.25
  107.  
  108. expenses = food_price + hotel_price
  109.  
  110. for day in range(1, days + 1):
  111.     expenses += float(input()) * price_km
  112.     if day % 3 == 0 or day % 5 == 0:
  113.         expenses += expenses * 0.4
  114.     if day % 7 == 0:
  115.         expenses -= expenses / people
  116.     if expenses > budget:
  117.         print(f"Not enough money to continue the trip. You need {(expenses - budget):.2f}$ more.")
  118.         break
  119.  
  120. if budget >= expenses:
  121.     print(f"You have reached the destination. You have {(budget - expenses):.2f}$ budget left.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement