The present value (PV) or current value (CV) of a future sum of money over a time period of \(n\) years and at an interest rate of \(p\), is the amount that when invested at the specified interest rate for the period of \(n\) years, will yield exactly the given sum. Simply put, it is the current value of a sum of money that will only be available at some point in the future.

Instead of a back calculation based on the interest rate, it can also be done based on inflation; if someone will receive € 100 in a year, but inflation during that year will be 4%, they will be able to buy less with that € 100 at that time than with € 100 they have in their wallet now. That € 100 now can be compared (in terms of purchasing power) to € 104 in 1 year. But that € 100 in 1 year can be compared to € 96,15 (100/1.04) now. The present value of that € 100 is thus € 96,15.

Net Present Value (NPV)

The present value of amounts to be paid out is calculated in the same way. This allows for a comparison of the effects of expenditures and incomes that occur at different points in time. By subtracting the present value of costs from the present value of revenues, the so-called Net Present Value (NPV) is obtained.

Calculation

The net present value (NPV) can be calculated using the following formula, where \(I\) represents the investment that preceded the project, \(R_t\) represents the return in year \(t\) (this is the difference between the income and the expenses), \(i\) represents the market interest rate as a percentage (for example, \(0.05\) represents an interest rate of \(5\%\)), and \(n\) indicates the number of years that the project runs.

\[\text{NPV} = \left(\sum^n_{t=0} \frac{R_t}{(1 + i)^t}\right) - I\]

Task

In this exercise, you will create a program that determines the profit (or loss) generated by a project, based on its net present value.

Input

  1. The user enters the amount of the investment (in euros) made prior to the project.
  2. The user enters the number of years the project runs.
  3. The user enters the interest rate. An interest rate of, for example, 8%, is entered by the user as \(0.08\), as in the formula.
  4. For each year of the project’s duration, the user enters the income and expenses of that year.
  5. Your program calculates the net present value over the specified number of years and displays the result to the user.

Output

Your program indicates whether a profit or loss is being made, how much that profit or loss amounts to, or whether the project is a break-even operation.

Example

Below is a sample output of the task. The text in red represents user input and is logically not printed out by your program.

200.50
3
0.05
11235.81
21692.37
43012.74
10469.63
62793.19
69823.64
De netto contante waarde over 3 jaar is € 13959.55.
Hoera! Er wordt een winst geboekt van € 13759.05!

In the above example, the investment resulted in a profit of approximately € 13750. However, the tests will also check for loss and break-even situations. In those cases, the final line should be replaced with:

Loss situation

Er is helaas een verlies van € 21.60.

Break-even situation

Er wordt exact break-even gedraaid.

Tips

Sources

Present Value (Wikipedia)1