Suppose you have a certain amount of money in a savings account that earns compound monthly interest, and you want to calculate the amount that you will have after a specific number of months. The formula, which is known as the future value formula, is: F=P×(1+i)t The terms in the formula are as follows: o F is the future value of the account after the specified time period. o P is the present value of the account. o i is the monthly interest rate. o t is the number of months. Write a program that prompts the user to enter the account’s present value, monthly interest rate, and the number of months that the money will be left in the account. The program should pass these values to a function named futureValue that returns the future value of the account, after the specified number of months. The program should display the account’s future value. i attached the screenshot of the output so the output should look like that.
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
Suppose you have a certain amount of money in a savings account that earns compound
monthly interest, and you want to calculate the amount that you will have after a specific
number of months. The formula, which is known as the future value formula, is:
F=P×(1+i)t
The terms in the formula are as follows:
o F is the future value of the account after the specified time period.
o P is the present value of the account.
o i is the monthly interest rate.
o t is the number of months.
Write a
interest rate, and the number of months that the money will be left in the account. The
program should pass these values to a function named futureValue that returns the
future value of the account, after the specified number of months. The program should
display the account’s future value.
i attached the screenshot of the output so the output should look like that.
Inorder to give user the option if he wants to use the service again I have used while loop logic at end,please find the code below with output:
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;
float futureValue(float pa,float r,int t){
float fvalue=pa*(pow((1+r),t));//applying the formulae
return fvalue;
}
int main() {
float pa,r;
int t;char c;
cout<<"What is the present value of account? ";
cin>>pa;
cout<<"What is the monthly interest rate? ";
cin>>r;
cout<<"For how many months the money will be left in account? ";
cin>>t;
cout<<"The account's future value is $"<<futureValue(pa,r,t)<<endl;
cout<<"DO you want to set another set of values?"<<"(y=yes): ";
cin>>c;
cout<<endl;
while(c=='y'){//for repetitive input from user
cout<<"What is the present value of account? ";
cin>>pa;
cout<<"What is the monthly interest rate? ";
cin>>r;
cout<<"For how many months the money will be left in account? ";
cin>>t;
cout<<"The account's future value is $"<<futureValue(pa,r,t)<<endl;
cout<<"DO you want to test another set of values?"<<"(y=yes): ";
cin>>c;
}
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images