/***************************************************
Compound Interest (Version 2)
Write a program that reads an annual interest rate
from the user, and computes the ammount of money
you'd have after 10 years at that interest rate,
if you made $100.00 payments into the account at
the beginning of each year. This version uses only
a single variable for the amount in the account,
and keeps changing its value at each compounding
step.
The formula for interest is this: If T is the
amount of money in your account at the beginning of
the year, and r is the annual interest rate, the
amount in your account at the end of the year is:
T*(1.0 + r/100.0)
***************************************************/
#include <iostream>
using namespace std;
int main()
{
// Read interest rate
double r;
cout << "Enter interest rate: ";
cin >> r;
// Compute 10 compounding steps
double T;
T = 100.0*(1.0 + r/100.0);
T = (T + 100.0)*(1.0 + r/100.0);
T = (T + 100.0)*(1.0 + r/100.0);
T = (T + 100.0)*(1.0 + r/100.0);
T = (T + 100.0)*(1.0 + r/100.0);
T = (T + 100.0)*(1.0 + r/100.0);
T = (T + 100.0)*(1.0 + r/100.0);
T = (T + 100.0)*(1.0 + r/100.0);
T = (T + 100.0)*(1.0 + r/100.0);
T = (T + 100.0)*(1.0 + r/100.0);
// Write out results
cout << "Final amount is: "
<< T << " dollars" << endl;
return 0;
}