Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- int main()
- {
- double amount, principal, rate;
- int compoundedTimes;
- cout << "Enter the principal amount: \n";
- cin >> principal;
- cout << "\nEnter the interest rate on your investment:\n";
- cin >> rate;
- cout << "\nEnter the amount of times your investment is compounded:\n";
- cin >> compoundedTimes;
- amount = principal * pow((1 + (rate / 100) / compoundedTimes), compoundedTimes);
- cout << setprecision(2) << fixed;
- cout << "\nInterest rate: " << setw(5) << rate << "%" << endl
- << "Times Compounded: " << setw(5) << compoundedTimes << endl
- << "Principal: $" << setw(5) << principal << endl
- << "Interest: $" << setw(5) << (rate / 100) * principal << endl
- << "Amount in savings: $" << setw(5) << amount << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement