Financial Planner
This assignment will introduce you to financial formulas commonly used in personal finance, business, and investment scenarios. You will choose and implement one of three C++ programs that calculates either future value (FV), present value (PV), or regular payments (PMT). Students should implement only one of these calculations (not all three).
At program start, your program should print a clear message telling the user which calculation it will perform (for example: This program will calculate future value). Then prompt the user only for the inputs required by that chosen calculation. These calculations are essential for understanding the value of money over time and making informed financial decisions.
- 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?”
- 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?”
- 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
Section titled “The Math”The future value and present value equations are cornerstone concepts in finance and economics that help 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:
- is the future value of the investment or cash flow,
- is the present value, i.e., the initial investment or starting amount of money,
- is the return or interest rate per period, as a decimal (e.g., 0.05 for 5%),
- 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):
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 are made into an account that earns interest, the future value formula depends on when the payments are made. By rearranging the terms, we can also solve for the recurring payment or the present value .
Case A: Payments at the Beginning of Each Period (Annuity Due)
Case B: Payments at the End of Each Period (Ordinary Annuity)
This is the default behavior if not specified. Note that the term associated with the payment is removed.
Use Cases
Section titled “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 Submission
Section titled “The Submission”This assignment requires you to implement one of the following three program variants. Your program should begin by printing which variant it implements (for example: This program will calculate recurring payments). Then prompt the user only for the inputs required by that variant and perform the calculation described.
- 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.
- 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.
- Recurring Payments Calculation: The program calculates the periodic 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.
Option 1: Future Value Calculation
Section titled “Option 1: Future Value Calculation”The user must provide the following inputs:
| Name | Description | Values | Invalid Values |
|---|---|---|---|
| Current amount | Initial amount of money (USD) to invest/save | Positive | Negative → print error and terminate immediately |
| Annual return rate | Expected annual rate as a percentage (e.g., 5 for 5%) | Positive | Negative → notify and override with default 5% |
| Number of periods (years) | Number of years the investment will grow | Strictly positive | Zero or negative → print error and terminate immediately |
| Recurring payment (PMT) | Amount added to savings each period (USD) | Positive | Negative → notify and override with default 0 |
| When are payments made | Timing of periodic payments: beginning or end of period | beginning or end (case-insensitive) | Invalid → notify and override with default (end) |
You can use equation (1) from above to calculate the future value.
The output will be the future value of the investment or item, formatted as currency, i.e., $12,345.67.
Option 2: Present Value Calculation
Section titled “Option 2: Present Value Calculation”The user must provide the following inputs:
| Name | Description | Values | Invalid Values |
|---|---|---|---|
| Future amount | The future sum to be received (USD) | Positive | Negative → print error and terminate immediately |
| Annual return rate | Expected annual discount/return rate as a percentage | Positive | Negative → notify and override with default 5% |
| Number of periods (years) | Years until the future amount is received | Strictly positive | Zero or negative → print error and terminate immediately |
| Recurring payment (PMT) | Periodic contribution or withdrawal amount (USD) | Positive | Negative → notify and override with default 0 |
| When are payments made | Timing of periodic payments: beginning or end of period | beginning or end (case-insensitive) | Invalid → notify and override with default (end) |
You can use equation (3) from above to calculate the present value.
The output will be the present value of the future sum, formatted as currency, i.e., $12,345.67.
Option 3: Recurring Payments Calculation
Section titled “Option 3: Recurring Payments Calculation”The user must provide the following inputs:
| Name | Description | Values | Invalid Values |
|---|---|---|---|
| Current savings | Initial amount of money already saved (USD) | Positive | Negative → print error and terminate immediately |
| Future value goal | Target amount to reach after specified period (USD) | Positive | Negative or ≤ Current savings → print error and terminate immediately |
| Annual return rate | Expected annual rate of return as a percentage | Positive | Negative → notify and override with default 5% |
| Number of periods (years) | Number of years to save | Strictly positive | Zero or negative → print error and terminate immediately |
| When are payments made | Timing of periodic payments: beginning or end of period | beginning or end (case-insensitive) | Invalid → notify and override with default (end) |
Ensure future value goal is greater than current savings.
You can use equation (2) from above to calculate the required recurring payments.
The output will be the required recurring payments needed to reach the future value goal, formatted as currency, i.e., $12,345.67.
Additional Details
Section titled “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?
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 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.
Critique an AI-Generated Output
Section titled “Critique an AI-Generated Output”You will critically evaluate an AI-generated solution or improvement. Your main submission must be your own work.
Choose one of the following options:
-
Critique a full solution generated by an AI language model (LLM)
- Generate a solution using an LLM (such as GitHub Copilot or ChatGPT), save it as
ai_planner.cpp, and add/commit it in addition to your own solution. - Review the code and identify at least two things the AI did well and two potential problems. Would you trust the solution in a real project? Why or why not?
- Write a short reflection (
ai_reflection.txt) summarizing your critique and commit it.
- Generate a solution using an LLM (such as GitHub Copilot or ChatGPT), save it as
-
Critique improvements proposed by an LLM for your own solution.
- Submit your own code to an LLM and ask for suggestions (for example by providing the course style guidelines), save it as
ai_planner.cpp, and add/commit it in addition to your own solution. - Review the proposed changes and discuss at least two helpful suggestions and two potential problems. Would you trust the changes in a real project? Why or why not?
- Write a short reflection (
ai_reflection.txt) summarizing your critique and commit it. Be specific about what you asked and the answers you received.
- Submit your own code to an LLM and ask for suggestions (for example by providing the course style guidelines), save it as
Your reflection must address:
- Two things the AI did well, with examples.
- Two potential problems or unclear items, with examples.
- Would you trust this AI-generated code/explanation in a real project? Why or why not?
Add and commit the code or explanation and your reflection to your GitHub Classroom repository.
Extra Credit Opportunities
Section titled “Extra Credit Opportunities”There are three optional tasks of varying difficulties that you can complete for extra credit.
Inflation Adjustment
Section titled “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:
where:
- is the real interest rate
- is the nominal interest rate (e.g., annual return from an investment)
- 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
Section titled “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.
Implement All Options
Section titled “Implement All Options”Implement all three calculation variants (Future Value, Present Value, and Recurring Payments) in a single program and let the user choose which calculation to perform at program start. The program should announce which calculation it will perform and then prompt for the inputs required by that choice.
Simulator
Section titled “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 a 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: