Question: Overview Write a C++ program that will act as a compound interest calculator. It should calculate the future value of an account after a 4-year
Overview
Write a C++ program that will act as a compound interest calculator. It should calculate the future value of an account after a 4-year period with a fixed interest rate.
Basic Program Logic
The first thing to do in the program is to create any variables that are needed to hold/save information for the program. To determine how many variables are needed, think about the information that will be entered by someone using the program and whether it is important for that information to be saved. Think about any calculations that will be performed by the program and whether the results of the calculations need to be saved. To determine the data type for the variables, think about what type of values that someone using the program will be entering or what kind of results will be produced by any calculations. (Note: to ease into writing this first program, the data type for the variables has been specified below.)
Ask the user of the program for the initial investment amount for the account. This is a dollar amount that should be stored in a float or double variable.
Ask the user of the program for the annual interest rate. This is a percentage that should be stored in a float or double variable.
Calculate the future value of the account using the initial investment amount and annual interest rate that were entered by the user of the program. Notice that the first formula calculates the value for year 1. The value for year 1 is then used to calculate the value for year 2. Year 2 is then used to calculate the value for year 3, which is then used to calculate the value for year 4 (the final year).
Value for year 1 = initial investment + (initial investment * interest rate / 100) Value for year 2 = Value for year 1 + (Value for year 1 * interest rate / 100) Value for year 3 = Value for year 2 + (Value for year 2 * interest rate / 100) Value for year 4 = Value for year 3 + (Value for year 3 * interest rate / 100) Future value of the account = Value for year 4
Finally, display the future value of the account (the value for year 4) as shown in the output below.
Program Requirements
Note: DO NOT put this box within cout statements. It should NOT be displayed as part of the output from the program.
/*************************************************************** CSCI 240 Program 1 Spring 2022 Programmer: Section: Date Due: Purpose: The purpose of this program is to calculate compound interest over a 4 year period. The user is prompted for the initial investment amount and the annual interest rate for the investment. ***************************************************************/
#include#include using namespace std;
-
At the top of the C++ source code, include a documentation box that resembles the following, making sure to put your name after the "Programmer" label, the section of CSCI 240 that you're in after the "Section" label, and the due date for the program after the "Date Due" label. A box similar to this one should be put in EVERY source code file that is handed in this semester.
-
Include the following lines of code BELOW the documentation box:
-
Use type float or double for all the variables. Make sure to use meaningful variable names.
-
It is okay to assume that the interest rate is entered as a percentage. For example, if the interest rate is 5%, the user will enter 5 or 5.0.
-
Make sure and test the program with values other than the ones supplied in the sample output.
-
Hand in a copy of the source code (the .cpp file) on Blackboard.
Output
A single run of the program should resemble the following:
How much is the initial investment amount? 5000 What is the annual interest rate? 6.2 ************************************** Investment Results ************************************** Initial Investment 5000 Annual Interest Rate 6.2 Future Account Value 6360.16
Or
How much is the initial investment amount? 1200.25 What is the annual interest rate? 4 ************************************** Investment Results ************************************** Initial Investment 1200.25 Annual Interest Rate 4 Future Account Value 1404.12
Note: The values that are displayed in red are the values entered by the user.
Extra Credit
For up to 5 points of extra credit, add code that will display the yearly value of the account for the 4-year period and the amount of increase from year to year for the 4-year period.
Note about extra credit: the points will ONLY be awarded if the required portions of the assignment work correctly. In other words, don't take short cuts in the rest of the program because it is assumed that 5 extra points will be awarded.
Extra Credit Output
How much is the initial investment amount? 5000 What is the annual interest rate? 6.2 ************************************** Investment Results ************************************** Initial Investment 5000 Annual Interest Rate 6.2 Year 1 Account Value 5310 -- increase of 310 Year 2 Account Value 5639.22 -- increase of 329.22 Year 3 Account Value 5988.85 -- increase of 349.632 Future Account Value 6360.16 -- increase of 371.309
Or
How much is the initial investment amount? 1200.25 What is the annual interest rate? 4 ************************************** Investment Results ************************************** Initial Investment 1200.25 Annual Interest Rate 4 Year 1 Account Value 1248.26 -- increase of 48.01 Year 2 Account Value 1298.19 -- increase of 49.9304 Year 3 Account Value 1350.12 -- increase of 51.9276 Future Account Value 1404.12 -- increase of 54.0048 (<-- Note: this value might display as 54.0047 - that's okay)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
