68 774
Assignments Done
98,8%
Successfully Done
In January 2019

# Answer to Question #66874 in C++ for Aniqa

Question #66874
Write a program that calculates how much money you'll end up with if you invest an amount of money at a fixed interest rate, compounded yearly. Have the user furnish the initial amount, the number of years, and the yearly interest rate in percent. Some interaction with the program might look like this: Enter initial amount: 3000 Enter number of years: 10 Enter interest rate (percent per year): 5.5 At the end of 10 years, you will have 5124.43 dollars. At the end of the first year you have 3000 + (3000 * 0.055), which is 3165. At the end of the second year you have 3165 + (3165 * 0.055), which is 3339.08. Do this as many times as there are years. Use while loop to make all calculations.
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
int years = 10;
double amount = 3000.0, interestRate = 5.5;

cout<<"Enter initial amount: ";
cin>>amount;
cout<<"Enter number of years: ";
cin>>years;
cout<<"Enter interest rate (percent per year): ";
cin>>interestRate;

interestRate/=100;

cout<<"At the end of "<<years<<" years, you will have "<<amount * pow((1 + interestRate), years)<<" dollars.";

for (int i = 1; i <= years; i++)
{
cout<<"At the end of the "<<i<<" year you have "<<amount<<" + ("<<amount<<" + "<<interestRate<<"), which is ";
amount+=amount*interestRate;
cout<<amount<<endl;
}

cout<<"At the end of "<<years<<" years, you will have "<<amount<<" dollars.";

return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!