Advertisement
SimeonTs

SUPyF Exam 24.03.2019 - 01.Build a Building

Aug 13th, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.73 KB | None | 0 0
  1. """
  2. Basics OOP Principles
  3. Check your solution: https://judge.softuni.bg/Contests/Practice/Index/1590#0
  4.  
  5. SUPyF Exam 24.03.2019 - 01.Build a Building
  6.  
  7. Problem:
  8. We are going to try to build a building. For that we will receive the budget, of course we have initial capital –
  9. m  and after that we will receive n – the number of investors who are interested to take place in our project.
  10. In the next n-lines we will receive numbers (one at a row) – the money which investors want to give us.
  11. For every investor we must print information in the following format:
  12.  
  13. ‘Investor {number} gave us {money_given}.’
  14. Where {money_given} is formatted two digits after the decimal point.
  15.  
  16. If at some point we have enough money to build our building we should stop taking investors money and print:
  17.  
  18. ‘We will manage to build it. Start now! Extra money - {extra_money}.”
  19.  
  20.  
  21. If we didn’t collect enough capital after all investors’ money we must print:
  22.  
  23. ‘Project can not start. We need {money} more.’
  24.  
  25. Input
  26. You will recieve on the first 3 lines:
  27. • budget – the budget we need to build the building [floating  number]
  28. • m – the initial capital we have[floating number]
  29. • n – number of investors [integer number]
  30. For each investor you will receive:
  31. • money – The money that this investor has given to us [floating  number]
  32.  
  33. Output
  34. If you have enough money at some point
  35. • „We will manage to build it. Start now! Extra money - {extra_money}.”
  36. Where extra_money is the money which has left, formatted two digits after decimal point
  37. If you do not have enough money after all investors have invested print:
  38. • „Project can not start. We need {difference} more.”
  39. Where {money} is the money you need to reach the planned budget, formatted two digits after decimal point.
  40.  
  41. Example input/output:
  42.    Input:
  43.        2250000
  44.        675000
  45.        3
  46.        1000000
  47.        750000
  48.        450000
  49.    Output:
  50.        Investor 1 gave us 1000000.00.
  51.        Investor 2 gave us 750000.00.
  52.        We will manage to build it. Start now! Extra money - 175000.00.
  53.    Input:
  54.        15000000
  55.        300000.99
  56.        2
  57.        2000000.37
  58.        8000000.25
  59.    Output:
  60.        Investor 1 gave us 2000000.37.
  61.        Investor 2 gave us 8000000.25.
  62.        Project can not start. We need 4699998.39 more.
  63. """
  64.  
  65. budget = float(input())
  66. m = float(input())
  67. n = int(input())
  68.  
  69. for investor in range(1, n + 1):
  70.     money = float(input())
  71.     m += money
  72.     print(f"Investor {investor} gave us {money:.2f}.")
  73.     if m >= budget:
  74.         print(f"We will manage to build it. Start now! Extra money - {(m - budget):.2f}.")
  75.         break
  76.  
  77. if budget > m:
  78.     print(f"Project can not start. We need {(budget - m):.2f} more.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement