fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main ()
  7. {
  8. float principal;
  9. float rate;
  10. float com;
  11. cout << "Interest Rate: ";
  12. cin >> rate;
  13. cout << "\nTimes Compounded: ";
  14. cin >> com;
  15. cout << "\nPrincipal: $ ";
  16. cin >> principal;
  17. rate/=100;
  18. float amount = principal * (pow((1+ (rate/com)),com ));
  19. float interest = amount - principal;
  20. cout << fixed << setprecision(2) << "\nInterest: $" << interest;
  21. float amount = interest - principal;
  22. cout << "\nAmount in Savings: $" << amount;
  23. return 0;
  24. }
Compilation #stdin #stdout 0.01s 5316KB
stdin
4.25 12 1000
stdout