Created
October 13, 2011 21:10
-
-
Save danvas/1285534 to your computer and use it in GitHub Desktop.
C++ code that calculates compound interests. (Exercise from Deitel & Deitel)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iomanip> | |
using namespace std; | |
int main() | |
{ | |
for (int interest = 5; interest <=10; interest++) | |
{ | |
double amount = 1000.00; | |
cout << "Interest Rate: " << interest << "%" | |
<< "\nYear" << setw(21) << "Amount on deposit" << endl; | |
cout << fixed << setprecision(2); | |
for (int year = 1; year <= 10; year++) | |
{ | |
amount *= ( 1 + (static_cast<double>(interest)/100) ); | |
cout << setw(4) << year << setw(21) << amount << endl; | |
} | |
cout << "\n" << endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment