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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -