Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int principal = 1000;
  10. int years = 1; //counter
  11. double balance = 0.0;
  12. double rate = .02;
  13.  
  14. do
  15. {
  16. cout << "Year " << years << ":" << endl;
  17.  
  18. while (rate < .05)
  19. {
  20. balance = principal * pow(1 + rate, years); //display rate with no decimal place
  21. cout << fixed << setprecision(0);
  22. cout << " Rate" << rate * 100 << "%: $";
  23. cout << setprecision(2) << balance << endl; //display balance with two decimal places
  24. rate += .01;
  25. }
  26. years += 1;
  27. } while (years < 6);
  28.  
  29. system("pause");
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement