How do you use e to power of in this case?

Pages: 12
/facepalm
I gave general usage of pow without any assumptions about e. Then I replaced e with the e without any second thought. Good catch.
Last edited on
I'm still not getting the correct total though ?

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
32
33
#include <iostream> 
#include <cmath> 
#include <iomanip> 
using namespace std;

int main()
{
	//declare identifiers 
    double rate = 0.0; 
	double time = 0.0;
	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): ";
	cin >> dollars;
	cout << "Enter the interest rate: " ;
	cin >> rate;
    cout << "Enter duration in year(t): " ;
	cin >> time;
    cout << "   Your balance after 5 years is " << total; 

	cout << endl; 

	//terminate program
	system("pause");
	return 0;
}
Ok, I have this but the dollars aren't initialized.

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
32
33
#include <iostream> 
#include <cmath> 
#include <iomanip> 
using namespace std;

int main()
{
	//initialize identifiers 
    double rate= 0.0; 
	double time= 0.0;
	float dollars= 0.0;
    float total= 0.0; 

    total= dollars * (pow(exp(1.0), rate*time)); 

	cout << fixed << showpoint << setprecision(2);
     
    //Enter values
	cout << "Enter the money you want to deposit now(P): ";
	cin >> dollars;
	cout << "Enter the interest rate: " ;
	cin >> rate;
    cout << "Enter duration in year(t): " ;
	cin >> time;
	total= dollars * (pow(exp(1.0), rate*time));
    cout << "   Your balance after 5 years is " << total; 

	cout << endl; 

	//terminate program
	system("pause");
	return 0;
}
Last edited on
Remove line 14. You do not need it: all calculations are done on line 25.

and listen to ne555 advice and modify line 25:
total= dollars * exp(rate*time);
I got it, thanks a lot. After I just put it after the cin >> time; it worked.
Last edited on
Wow, it looks so much easier than I made it out to be. Thanks
Topic archived. No new replies allowed.
Pages: 12