Raising a number to a power in Java
^
in java does not mean to raise to a power. It means XOR.
You can use java's Math.pow()
And you might want to consider using double
instead of int
—that is:
double height;
double weight;
Note that 199/100
evaluates to 1.
we can use
Math.pow(2, 4);
this mean 2 to the power 4 (2^4)
answer = 16