Skip to content

Financial Planner

This assignment will introduce you to financial formulas commonly used in personal finance, business, and investment scenarios. You will write a C++ program that calculates future value (FV), present value (PV), or regular payments (PMT) based on user input. These calculations are essential for understanding the value of money over time and making informed financial decisions.

  1. Future Value (FV): Used to calculate how much an investment or savings will grow to after a certain number of periods, considering regular payments and interest. Example: “How much will my retirement savings grow to after 30 years if I save $500 per month?”
  2. Present Value (PV): Used to determine the current value of a future sum of money or cash flows, discounted at a specific interest rate. Example: “What is the current worth of receiving $10,000 five years from now?”
  3. Regular Payments (PMT): Used to calculate how much needs to be paid regularly to achieve a specific future goal. Example: “How much should I save every month to have $100,000 in 10 years?”

Stage, commit, and push your changes to your assignment repository on GitHub classroom (check the Canvas assignment for the invite link). After doing so, you should be able to see your up-to-date work on your assignment repository page in your web browser. If so, you have successfully submitted your assignment.

Make sure to follow the best practices and guidelines mentioned in the style guide, and check your assignment rubric in Canvas.

Don’t forget to attend your assignment demo, which you should have already scheduled by this point.

The Math

The future value FVFV and present value PVPV equation is a cornerstone concept in finance and economics that helps calculate how the value of money changes over time, accounting for interest or discount rates. These equations use the concept of the time value of money, which states that a dollar today is worth more than a dollar in the future due to its earning potential.

The future value is the amount an investment made today will grow to after earning interest over a specified period:

FV=PV(1+r)nFV = PV \cdot (1 + r)^n
  • FVFV is the future value of the investment or cash flow,
  • PVPV is the present value, i.e., the initial investment or starting amount of money,
  • rr is the return or interest rate per period, as a decimal (e.g., 0.05 for 5%),
  • nn is the number of periods (e.g., years, months).

We can also calculate the present value of a future amount of money, which is the amount that needs to be invested today to grow to a specified future value (i.e., the current worth of a future sum of money or cash flow, discounted at a specific interest rate):

PV=FV(1+r)nPV = \frac{FV}{(1 + r)^n}

When we incorporate regular payments (PMT) into the future value (FV) and present value (PV) equations, it allows us to calculate the value of money when periodic cash flows (like loan payments, savings contributions, or withdrawals) are involved. This is commonly used for loans, annuities, and retirement planning.

When regular, fixed payments PMTPMT are made into an account that earns interest, the future value formula becomes:

FV=PV(1+r)n+PMT(1+r)(1+r)n1rFV = PV \cdot (1 + r)^n + PMT \cdot (1 + r) \cdot \frac{(1+ r)^n - 1}{r}

For the keen-eyed, you may notice the extra (1+r)(1 + r) in the formula. This is because the payment is made at the beginning of each period, so it earns interest for one additional period compared to the principal. You should leave that out if the payment is made at the end of each period. This also applies to the equation below.

You can shuffle the above equations to calculate recurring payments PMTPMT or the present value PVPV :

PMT=FVPV(1+r)n(1+r)(1+r)n1rPMT = \frac{FV - PV \cdot (1 + r)^n }{(1 + r) \cdot \frac{(1 + r)^n - 1}{r}} PV=FVPMT(1+r)(1+r)n1r(1+r)nPV = \frac{FV - PMT \cdot (1+r) \cdot \frac{(1 + r)^n - 1}{r}}{(1 + r)^n}

Use Cases

Here are some use cases where these equations can be applied.

Retirement Savings

You can use these equations to calculate how much you need to save each month to reach a specific retirement goal. For example, if you want to retire in 30 years with $1,000,000, and you expect a 7% annual return on your investments (adjusted for inflation), you can calculate the monthly savings needed to reach that goal.

Loan Payments

You can use these equations to calculate the monthly payment needed to pay off a loan. For example, if you take out a $100,000 loan at 5% interest for 30 years, you can calculate the monthly payment needed to pay off the loan.

Inflation Prediction

You can use these equations to predict the future value of an item based on its current price and expected inflation rate. For example, if an item costs $1,000 today and the inflation rate is 2% per year, you can calculate how much the item will cost in 10 years.

Business Valuation

You can use these equations to value a business based on its future cash flows. For example, if a business is expected to generate $1,000,000 in cash flow each year for the next 10 years, you can calculate the present value of those cash flows to determine the value of the business.

The Program

When the program runs, prompt the user to choose between three options:

  1. Future Value Calculation: The program calculates how much the user’s current savings will grow over a specified number of years with or without regular contributions. Alternatively, it can calculate the future value of a specific item with an expected annual inflation rate. The program will display the future value of the investment or the cost of the item after the specified number of years.
  2. Present Value Calculation: The program calculates the current value of a future sum of money, discounted at a specific interest rate. The program will display the present value of the future sum.
  3. Recurring Payments Calculation: The program calculates the monthly savings required to reach a desired future value over a specified number of years for a given rate of return. It can take into account current savings.

If the user selects an invalid option, display an error message and terminate the program immediately.

Option 1: Future Value Calculation

The user must provide the following inputs:

  • Current amount: Initial amount of money (USD). If the user enters a negative value, print an error to the terminal and terminate the program immediately.
  • Annual return rate: Expected annual rate as a percentage (e.g., 5 for 5%, must be positive). If the user enters a negative value, notify the user that negative values aren’t allowed and override their entry with a default of 5%.
  • Number of periods (years): The number of years the investment will grow (strictly positive) or when the purchase is expected to be made. If the user enters a negative value, print an error to the terminal and terminate the program immediately.
  • Recurring payment: The amount added to savings each period (USD). If the user enters a negative value, notify the user that negative values aren’t allowed and override their entry with a default of 0.
  • When are payments made: The user can choose between payments made at the beginning or end of each period. Ask only if recurring payments are not zero. If the user enters an invalid option, notify the user that the input is invalid and override their entry with the default option.

The output will be the future value of the investment or item, formatted as currency.

Option 2: Present Value Calculation

The user provides the following inputs:

  • Future amount: The future sum of money (USD). If the user enters a negative value, print an error to the terminal and terminate the program immediately.
  • Annual return rate: Expected annual rate as a percentage (e.g., 5 for 5%, must be positive). If the user enters a negative value, notify the user that negative values aren’t allowed and override their entry with a default of 5%.
  • Number of periods (years): The number of years until the future amount is received (strictly positive). If the user enters a negative value, print an error to the terminal and terminate the program immediately.
  • Recurring payment: The amount added to savings each period (USD). If the user enters a negative value, notify the user that negative values aren’t allowed and override their entry with a default of 0.
  • When are payments made: The user can choose between payments made at the beginning or end of each period. Ask only if recurring payments are not zero. If the user enters an invalid option, notify the user that the input is invalid and override their entry with the default option.

The output will be the present value of the future sum, formatted as currency.

Option 3: Recurring Payments Calculation

The user provides the following inputs:

  • Current savings: Initial amount of money (USD). If the user enters a negative value, print an error to the terminal and terminate the program immediately.
  • Future value goal: The target savings amount after the specified period (USD). If the user enters a negative value, print an error to the terminal and terminate the program immediately.
  • Annual return rate: Expected annual rate of return as a percentage (e.g., 5 for 5%, must be positive). If the user enters a negative value, notify the user that negative values aren’t allowed and override their entry with a default of 5%.
  • Number of periods (years): The number of years to save (strictly positive). If the user enters a value that is equal to zero or less, print an error to the terminal and terminate the program immediately.
  • When are payments made: The user can choose between payments made at the beginning or end of each period. Ask only if recurring payments are not zero. If the user enters an invalid option, notify the user that the input is invalid and override their entry with the default option.

Ensure future value goal is greater than current savings.

The output will be the required recurring payments needed to reach the future value goal, formatted as currency.

Additional Details

Even though the formula is very flexible, make sure to validate inputs as described above, and handle errors or defaults gracefully. For example, what happens if the user inputs a return rate of zero or if the user wants to save for 0 years?

Your code should rigorously adhere to all of the course’s C++ style guidelines. That includes breaking it up into several modularized functions each with a single responsibility.

The Submission

The provided template code includes a file named planner.cpp, which is mostly empty. Your task is to complete this file to create a C++ program that performs the steps outlined above.

You need to validate user input and manage errors as described in the program requirements. If the user enters invalid input, print an error message to the terminal and terminate the program immediately.

Extra Credit Opportunities

There are three optional tasks of varying difficulties that you can complete for extra credit.

Inflation Adjustment

Modify the program to account for inflation in the future value calculations. The user should be able to provide an expected (annual) inflation rate, and the program should adjust the future value calculations accordingly.

The adjustment for inflation involves considering the real interest rate instead of the nominal interest rate. The real interest rate reflects the true growth of money after accounting for inflation. It can be calculated using the Fisher Equation:

(1+rreal)=(1+rnominal)(1+rinflation)(1 + r_{\text{real}}) = \frac{(1 + r_{\text{nominal}})}{(1 + r_\text{inflation})}

where:

  • rrealr_{\text{real}} is the real interest rate
  • rnominalr_{\text{nominal}} is the nominal interest rate (e.g., annual return from an investment)
  • rinflationr_\text{inflation} is the expected annual inflation rate

The real interest rate is then used in the FV formula instead of the nominal interest rate.

This adjustment is critical for scenarios where inflation significantly impacts long-term financial planning, such as retirement or education savings.

Compounding Periods

Allow the user to specify the compounding period (e.g., monthly, quarterly, annually) for the interest rate. Adjust the calculations accordingly. You can choose the periods supported, but it must be more than one period.

Interactive Mode

Implement an interactive mode where the user can perform multiple calculations without restarting the program. After each calculation, the user should be prompted to choose another calculation or exit the program.

Simulator

Here’s a small interactive simulator to test your program. You can input values for each scenario and see the expected output. This simulator includes the extra-credit options for inflation adjustment and compounding periods. Leave the inflation rate at 0% with an yearly compounding period to match the base requirements.

Future Value: $3,445.51

Alternatively, you can use the following links to test your program with different scenarios: