help with math statement...
new to C#... trying to build a compound interest calculation.
the error i get is in the for loop on the line:
amount = principal * (1 + rate) ^ year;
"Operator "*" cannot be applied to operands of type "decimal" and "double"
also i noticed in this line, the ^ .(in vb the ^ is for exponents),
i want to know if there is an equivalent in C#.
can anyone guide me to the light?
Code:
double rate;
int year;
string output;
decimal amount, principal;
principal = System.Convert.ToDecimal(txtDeposit.Text);
rate = System.Convert.ToDouble(txtInterest.Text);
output = "Year Amount on Deposit"
for(int iX = 1; iX < 11; iX++)
{
amount = principal * (1 + rate) ^ year;
ouput += iX + " " + System.String.Format("{0:C}", amount) + "\n";
}
MessageBox.Show(output, "Compound Interest");
thanks in advance