Program to compute compound interest The formula to compute

Program to compute compound interest.
The formula to compute compound interest is Amount=Principal * Term where Principal is the amount to be invested and Term is the expression (1 + monthlyRate)(12*years)
The variable monthlyRate is the annual rate divided by 12.
Write a program to ask the user for the Principal, the number of years of the investment and the annual interest rate and to compute and display the amount of the investment and the amount of interest. All dollar amount are to be displayed correct to 2 decimal places and preceded by $.

Sample run:
What is the principal? 650
What is the annual interest rate? 6.8
What is the number of years? 7

Principal= $650.00
Number of years= 7
Annual rate =6.80%

The total amount is $1044.85
The amount of interest is $394.85
Press any key to continue . . .

Solution

#include<iostream>
#include<cmath>

#include<cstdlib>
using namespace std;
int main()
{
double principal;
double rate;
double amount;
double interest;
int years;
cout<<\"\ enter principal : $ \";
cin>>principal;
cout<<\"\ enter rate :\";
cin>>rate;
cout<<\"\ enter years :\";
cin>>years;
double monthlyRate=rate/12;
double term=pow((1+monthlyRate),(12*years));
amount=principal*term;
interest=amount-principal;
cout<<\"\ total amount is $ \"<<amount;
cout<<\"\ amount of interest is $ \"<<interest;

cout<<\"\ press any key to continue...\";

char c;

cin>>c;

exit(0);
return 0;
}

Program to compute compound interest. The formula to compute compound interest is Amount=Principal * Term where Principal is the amount to be invested and Term

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site