Create a simple program to help calculate the total cost of printing posters. First, ask the user:
How many posters will be printed?
Then, calculate the total cost according to the following rules:
- The ink costs 1.25 USD per poster.
- The printery needs to buy a roll of paper on which the posters will be printed. Each roll costs 50 USD and can make 200 posters. The customer pays for entire rolls.
Example 1: To print 1 poster, the customer needs to buy 1 roll of paper (50 USD) and pay for the ink (1.25 USD). Total cost: 51.25 USD.
Example 2: To print 50 posters, the customer needs to buy 1 roll of paper (50 USD) and pay for the ink (50 * 1.25 = 62.50 USD). Total cost: 112.50 USD.
Example 3: To print 250 posters, the customer needs to buy 2 rolls of paper (2 * 50 = 100 USD) and pay for the ink (250 * 1.25 = 312.50 USD). Total cost: 412.50 USD.
Print the answer in the following way:
This will cost {price} USD.
The biggest challenge in this exercise is to correctly calculate the cost of rolls of paper. You could use integer division (//
), but this will not work:
number_of_posters // 200
For 50 posters, this equation will yield 0, which is not correct. You could add 1 to the score each time, but the result will still be incorrect for some values, such as 200 (200//200 + 1 = 2
, but should be 1).
The trick is to add (200-1
) before dividing by 200:
(number_of_posters+199) // 200