java - The operator ^ is undefined for the argument type(s) Double, int -



java - The operator ^ is undefined for the argument type(s) Double, int -

this question has reply here:

pow (x,y) in java 4 answers

here code

public class interestcalculatordemo { public static void main(string[] args) { integer n=20; integer p=50000; double r=0.5; //formula a= p(1+r)^n (int = 0; < n; i++) { double x=p*(1+r); double value=x^i; system.out.println(value); } } }

when run give error

exception in thread "main" java.lang.error: unresolved compilation problem: operator ^ undefined argument type(s) double, int @ com.priyan.exam2010.interestcalculatordemo.main(interestcalculatordemo.java:12)

please help me sort out issue

thanks

^ not powerfulness operator, bitwise exclusive or (xor), defined integer types.

you should utilize math.pow instead:

double value = math.pow(x, i);

java

Comments