Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- int main()
- {
- int principal = 1000;
- int years = 1; //counter
- double balance = 0.0;
- double rate = .02;
- do
- {
- cout << "Year " << years << ":" << endl;
- while (rate < .05)
- {
- balance = principal * pow(1 + rate, years); //display rate with no decimal place
- cout << fixed << setprecision(0);
- cout << " Rate" << rate * 100 << "%: $";
- cout << setprecision(2) << balance << endl; //display balance with two decimal places
- rate += .01;
- }
- years += 1;
- } while (years < 6);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement