C++ program Assuming there are no deposits other than the original investment, t
ID: 3818251 • Letter: C
Question
C++ program
Assuming there are no deposits other than the original investment, the balance in a savings account after one year may be calculated as:
Amount = Principal * (1 + Rate/T) ^T
where Principal is the balance in the account, Rate is the annual interest rate, and T is the number of times the interest is compounded during a year. (e.g., T is 4 if the interest is compounded quarterly.)
Write a program that asks for the principal, the interest rate, and the number of times the interest is compounded. It should display a report similar to the following:
Interest Rate: 4.25%
Times Compounded: 12
Principal: $ 1000.00
Interest: $ 43.33
Final balance: $ 1043.33
In addition, your program should also ask user her/his full name ( first, and last name) and display the following message : ( if the user's name is John Doe and amount in savings is $1043.34)
John Doe has a total amount of $ 1043.34 in the savings account.
Explanation / Answer
#include<iostream.h>
#include<math.h> // used for pow() function
#include<iomanip.h>
#include<string.h> //used for string function
using namespace std;
int main()
{
double Principal;
double Interest_Rate;
double Compound;
string fname,lname, fulName;
cout<<"What is your First name ?:"<<endl;
cin>>fname;
cout<<"What is your Last name ?:"<<endl;
cin>>lname;
fullName = fname + lname;
cout<<" How much amount do you want to invest/deposit?:" <<endl;
cin>>Principal;
cout<<"What rate of interest you want ?:" <<endl;
cin>>Interest_Rate;
cout<<"How many times has your interest been compounded?:" <<endl:
cin>>Compound;
double temp = 1 + (Interest_Rate/Compound);
double amount = Principal * pow(temp,Compound);
cout<< "Interest Rate: "<<Interest_Rate * 100 <<endl;
cout<<"Times Compounded: "<<Compound<< endl;
cout<<"Principal: $"<< Principal <<endl;
cout<<"Interest: $"<< Interest_Rate * Compound <<endl;
cout<<"Final balance: $"<< amount <<endl;
cout<<fullName " has a total amount of $" <<amount <<"in the saving account"<<endl;
system("pause");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.