copyright Steve J. Hodges   http://steveh.net/cs19/cs19-hw01.html

CS 19 Spring 2012

Assignment 1 - Back To The Future
a future value calculator

Filename

fv.cpp

Overview

Write a program to calculate the future value (FV) of an amount of money to be invested (the present value, or PV) with compound interest. If you don't remember how compound interest works, you might want to review the first part of the Wikipedia article on compound interest.)

Program Description

The program should begin with the output on a line by itself, your name and email. The second line output should list the assignment title and number. Then, prompt the user for the amount to be invested, the annual interest rate, the number of compounds to be made each year, and the number of years the money is to be invested (in that order, one per line). Then, output the resulting future value. Make sure that your output is clear and concise. Your result must be formatted to two decimal places. Your program should input from STDIN and send output to STDOUT.

Your program should have at least one function (to calculate and return the future value with the provided equation) in addition to main.

getting the correct answer

The equation for calculating the future is:
Future Value Calculation Formula
where PV is the amount invested, i is the interest rate per compound, and t is the total number of compounds that must be made.

For example, if $10,000 is invested at 12% annual interest rate, with monthly compounding for 4 years we would do the following calculations:

i = 0.12 / 12

t = 12 * 4
Future Value Calculation Formula Example
(FV) result = $16122.26

What to turn in

As usual, leave your .cpp file for this program ("fv.cpp") in your home directory on pengo.

Suggestions

You may wish to use the following program as a model. Note that this example is not necessarily properly indented or formatted. Don't forget to follow the Program Guidelines in your submission!

// Calculates volume of a cylinder #include <iostream> #include <cmath> // for M_PI (portable?) using namespace std; double calcCylinderVolume(double, double); int main(){ double height=0.0, radius=0.0, volume=0.0; cout << endl << "Cylinder Voulume Calulator" << endl; cout << "What is the cylinder height? " << endl; cin >> height; cout << "What is the cylinder radius? "<< endl; cin >> radius; volume = calcCylinderVolume(height, radius); cout << endl << "A cylinder with height " << height; cout << " and radius " << radius; cout << " has a volume of " << volume << "." << endl; } double calcCylinderVolume(double h, double r){ return h * M_PI * r * r; }