Advertisement
Guest User

Untitled

a guest
Sep 15th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. double amount, principal, rate;
  10. int compoundedTimes;
  11.  
  12. cout << "Enter the principal amount: \n";
  13. cin >> principal;
  14.  
  15. cout << "\nEnter the interest rate on your investment:\n";
  16. cin >> rate;
  17.  
  18. cout << "\nEnter the amount of times your investment is compounded:\n";
  19. cin >> compoundedTimes;
  20.  
  21.  
  22. amount = principal * pow((1 + (rate / 100) / compoundedTimes), compoundedTimes);
  23.  
  24. cout << setprecision(2) << fixed;
  25.  
  26. cout << "\nInterest rate: " << setw(5) << rate << "%" << endl
  27.  
  28. << "Times Compounded: " << setw(5) << compoundedTimes << endl
  29.  
  30. << "Principal: $" << setw(5) << principal << endl
  31.  
  32. << "Interest: $" << setw(5) << (rate / 100) * principal << endl
  33.  
  34. << "Amount in savings: $" << setw(5) << amount << endl;
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement