Created
December 9, 2017 04:58
-
-
Save ebba0194/58db72daa65ad03f23e09fcd82258784 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
double calcInt (double, double, double, double&); | |
int main(){ | |
double deposit, ratePer, rateDec, endAmount, years, endBalance; | |
cout<<"Enter initial deposit: $"; | |
cin>>deposit; | |
cout<<"Enter interest rate (%): "; | |
cin>>ratePer; | |
rateDec = ratePer/100; | |
cout<<"Enter desired end amount: "; | |
cin>>endAmount; | |
endBalance = calcInt (deposit, rateDec, endAmount, years); | |
cout<<"\nIt will take "<<years<<" years." | |
<<"\nEnding balance = "<<endBalance; | |
return (0); | |
} | |
double calcInt (double deposit, double rateDec, double endAmount, double& years){ | |
double temp=deposit; | |
double endBalance; | |
int n = 0; | |
do{ | |
endBalance = temp+(temp*rateDec); | |
temp = endBalance; | |
n++; | |
}while (temp <= endAmount); | |
years = n; | |
return (endBalance); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment