1. ## Help with typecasting

The assignment asks to input these values:

D = Investment Amount (5000)
P = Interest (5.25)
Y = Number of Years (2.25)
M = Conversions/Year (4)

It tells me to use float for interest, and int for the rest.
I have to use this formula to calculate the Maturity value (S)
S = D ( 1 + P/M) to the power of YM

Using the data above S is suppose to equal 5622.60
When I debug I get 5065.62.

I think I have made an error in typecasting int to double or float to double

Code:
```// MaturityCalc.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <math.h>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
int m, y, d;
double s;
float p;

//keyboard input
cout << "Please input the following information";
cout << endl;
cout << "Investment Amount: ";
cin >> d;
cout << endl;
cout << "Interest Rate: ";
cin >> p;
cout << endl;
cout << "Conversions/Year: ";
cin >> m;
cout << endl;
cout << "Number of Years: ";
cin >> y;
cout << endl;
//end keyboard entry

y = y * m;
p = 1 + (p/100)/m;
pow ((double) p , (double)y);
s = d * p;
cout << "This is the result: " << (double)s;

system ("pause");

return 0;
}```

Note: This is my second assignment, first week of C++, I have very little knowledge of this.

Any help is appreciated.

2. If you have 2.25 years, then years needs to be a float or double.

3. Thanks for that, it fixed a glitch that was skipping y, but I'm still getting the same answer.

4. Are you getting (and ignoring) any compiler warnings?

Did you fix the data type or just cast around it?

5. No compiler errors. I'm not sure what your second comment means, sorry.

7. Code:
```// MaturityCalc.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <math.h>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
int m, d;
double s;
float p, y;

//keyboard input
cout << "Please input the following information";
cout << endl;
cout << "Investment Amount: ";
cin >> d;
cout << endl;
cout << "Interest Rate: ";
cin >> p;
cout << endl;
cout << "Conversions/Year: ";
cin >> m;
cout << endl;
cout << "Number of Years: ";
cin >> y;
cout << endl;
//end keyboard entry

y = y * m;
p = 1 + (p/100)/m;
pow ((double) p , (double)y);
s = d * p;
cout << "This is the result: " << (double)s;

system ("pause");

return 0;
}```

8. Were you planning to store the result of the pow anywhere handy?

9. Haha, that was it! Thank you very much!