Jan 29, 2015 at 8:58am UTC
so I have this, I'm trying to use the formula B=Pe^(rt) , P is dollars deposited in an account for t years with the interest rate of r. How do I use e to the power of something?? I don't really understand how to use it. thx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
//declare identifiers
float dollars;
float rate;
float time;
float total;
//initialize identifiers
total= (dollars*pow(exp(x), (rate*time)));
cout << fixed << showpoint << setprecision(2);
//Enter values
cout << "Enter the money you want to deposit now(P): " << dollars;
cout << "Enter the interest rate: " << rate;
cout << "Enter duration in year(t): " << time;
cout << " Your balance after 5 years is " << total;
cout << endl;
//terminate program
system("pause" );
return 0;
}
Last edited on Jan 29, 2015 at 9:00am UTC
Jan 29, 2015 at 9:44am UTC
by e
do you mean Euler number? If so, it is easy to get by using exp(1.0)
Jan 29, 2015 at 9:45am UTC
How would I use it to say e^(rate * time) ? Ya thats what I meant.
Last edited on Jan 29, 2015 at 9:46am UTC
Jan 29, 2015 at 9:47am UTC
I'm trying to do dollars* e ^(rate * time) to find the new balance.
Jan 29, 2015 at 9:48am UTC
I think I tried that too. Then what would I make e ?
Last edited on Jan 29, 2015 at 9:50am UTC
Jan 29, 2015 at 10:04am UTC
What is e exactly in your code?
MiiNiPaa wrote:by e
do you mean Euler number? If so, it is easy to get by using exp(1.0)
Last edited on Jan 29, 2015 at 10:04am UTC
Jan 29, 2015 at 10:09am UTC
Yes, but I tried that and it's not working.
Jan 29, 2015 at 10:18am UTC
But instead of numbers I have rate and time though, how do I incorporate that?
Jan 29, 2015 at 10:25am UTC
Ok I see sort of.. but if I want to choose what I want rate and time to be, would I put them equal to 0.0 or something?
Also I want total to equal that part like total = pow(exp(1.0), rate*time) too so what happens to total?
Sorry I'm a beginner, thanks.
Last edited on Jan 29, 2015 at 10:29am UTC
Jan 29, 2015 at 10:32am UTC
So I did something like this and it failed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
//declare identifiers
double rate = 1;
double time = 2;
float dollars;
float total=0.0;
//initialize identifiers
total= pow(exp(1.0), rate*time);
cout << fixed << showpoint << setprecision(2);
//Enter values
cout << "Enter the money you want to deposit now(P): " << dollars;
cout << "Enter the interest rate: " << rate;
cout << "Enter duration in year(t): " << time;
cout << " Your balance after 5 years is " << total;
cout << endl;
//terminate program
system("pause" );
return 0;
}
Last edited on Jan 29, 2015 at 10:33am UTC
Jan 29, 2015 at 10:41am UTC
So for what I need to do is choose a number, in my case the rate has to be 0.5 and the time has to be 5 and I have to input that and it asks enter the amount. So that's where I'm stuck.
Jan 29, 2015 at 10:50am UTC
I understand it partially.