Why are you casting the result as an int
? That will drop everything past the decimal point. Declare expcalc
and finalcalc
as double
instead to obtain an accurate result.
double expcalc = Math.pow(1.1, i);
double finalcalc = price * expcalc;