68 774
Assignments Done
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.
Expert's answer
#include <iostream>
#include <cmath>
using namespace std;

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

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


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 ";

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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions