230k views
5 votes
In this project, you will calculate the amount of an investment after a period of time. You will ask the user to enter the initial investment amount, the annual interest rate, the number of years, and the number of times the interest is compounded per year. The formula for the new investment value is: • Investment Value: A = ∗ #1 + ' ( ) (*, where P is your initial investment amount, r is the annual interest rate, t is the number of years, and n is the number of times the interest is compounded per year Here is a typical program run. project displays the value of an investment after a given number of years at a given interest rate. Month Day, 20XX Enter the initial investment amount: 1,000 Enter the annual interest rate: 0.03 Enter the number of years: 5 Enter the number of times the interest is compounded per year: 12 The investment value is: $1500

User Teudimundo
by
4.1k points

1 Answer

5 votes

Answer:

#include<iostream>

#include<cmath>

using namespace std;

int main()

{

int a=1;

while(a==1){

float P=0.0,R=0.0,T=0.0,A=0.0,n=0.0,nt=0.0;

cout<<"Enter your Initial Investment Amount : ";

cin>>P;

cout<<"Enter your Rate of Annual interest : ";

cin>>R;

cout<<"Enter No. of times the interest is compound : " ;

cin>>n;

cout<<"Enter Time (years) : ";

cin>>T;

nt=n*T;

A=P*pow((1+R/n),(nt));

cout<<"After "<<T<<" years, the initial investment of "<<P<<" is : "<<A;

cout<<"\\Enter 1 to continue or exit by pressing any other button";

cin>>a;

}

return 0;

}

Step-by-step explanation:

  • Get the essential values from user as an input and store them in variables.
  • Apply the following formulas to calculate years and initial investment.
  1. nt=n*T;
  2. A=P*pow((1+R/n),(nt));
  • Finally display the results.
User Luke Stevenson
by
4.4k points