math - Calculating the value of a mathematical function in Java -
i have function , trying list of calculations.
f(x) = (100)(1.1)^x how calculate out in java. tried loop value of x , end result of y, didn't work. might have been code inside. tried exponent of 1.1 , multiply 100, correct?
for(int = 1; i<=15; i++){ int expcalc = (int) math.pow(1.1, i); int finalcalc = price * expcalc; system.out.println(" " + finalcalc); } what doing wrong here?
why casting result int? drop past decimal point. declare expcalc , finalcalc double instead obtain accurate result.
double expcalc = math.pow(1.1, i); double finalcalc = price * expcalc;
Comments
Post a Comment