garryhtreez

5.29

Nov 20th, 2020
948
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. /* 5.29 Peter Minuit Problem
  2.    Deitel & Deitel C++ How to Program, 10th ed (Indian subcontinent adaptation)
  3.    Visual Studio Community 2019
  4. */
  5.  
  6. #include <iostream>
  7. #include <iomanip>
  8. #include <cmath>
  9. using namespace std;
  10.  
  11. int main() {
  12.    
  13.    cout << fixed << setprecision(2);
  14.    double principal{ 24.00 }; // initial amount before interest
  15.    cout << "After 395 years:\n\n";
  16.  
  17.    for (double rate{ 0.05 }; rate <= 0.10; rate += 0.01) {
  18.       double amount = principal * pow(1.0 + rate, 394);
  19.       cout << "Interest rate:    " << rate << setw(30) << "$" << amount << "\n\n";
  20.    }
  21.    return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment