In what concerns the continuous evaluation solving exercises grade during the semester, you should submit until 23:59 of October 26th
(this exercise will still be available for submission after that deadline, but without couting towards your grade)
[to understand the context of this problem, you should read the class #03 exercise sheet]
The Rubber Duck Hotel has an original way to charge its clients. The first night costs 50E, the second 25E (50/2), and the n-th night costs 50/n E. Can you calculate how much it will cost to stay for several nights?
Write a program that, given the number of nights n calculates and prints the nightly rate for each night and the total amount to be paid.
The input consists of a single integer n representing the number of nights.
The output should display the price for each night and the final total, formatted as:
"Night [i]: [price]E"
where [i]
is the night number"Total: [total_price]E"
All the daily prices and the total should be printed rounded to two decimal places.
The following limits are guaranteed in all the test cases that will be given to your program:
1 ≤ n ≤ 50 | Number of nights n |
Example Input 1 | Example Output 1 |
2 |
Night 1: 50.0E Night 2: 25.0E Total: 75.0E |
Example Input 2 | Example Output 2 |
4 |
Night 1: 50.0E Night 2: 25.0E Night 3: 16.67E Night 4: 12.5E Total: 104.17E |