^ 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.
GeeksforGeeks
geeksforgeeks.org โบ java โบ math-pow-method-in-java-with-example
Math pow() Method in Java with Example - GeeksforGeeks
March 28, 2025 - Example 1: This example demonstrates how to use the Math.pow() method in Java to calculate the power of a number (base raised to the exponent).
Oracle
docs.oracle.com โบ javase โบ 8 โบ docs โบ api โบ java โบ lang โบ Math.html
Math (Java Platform SE 8 )
October 20, 2025 - if the second argument is a finite odd integer, the result is equal to the negative of the result of raising the absolute value of the first argument to the power of the second argument ยท if the second argument is finite and not an integer, then the result is NaN. If both arguments are integers, then the result is exactly equal to the mathematical result of raising the first argument to the power of the second argument if that result can in fact be represented exactly as a double value.
Raising a number to a power in Java - Stack Overflow
Here is my code. For some reason my BMI is not calculated correctly. When I check the output on a calculator for this : (10/((10/100)^2))) I get 1000, but in my program, I get 5. I'm not sure wha... More on stackoverflow.com
What's the algorithm behind Math.pow() in Java - Stack Overflow
I just started with Java and as a first project I am writing a program that finds roots(cube root in this case) of a given number. Presently I am trying out Newton-Ralphson to achieve this. Here is... More on stackoverflow.com
Explain Java function Math.pow( ) with an example.
In Java, Math.pow( ) function returns the value of the first argument raised to the power of the second argument. More on knowledgeboat.com
Can somebody please help me with Math.pow and specifically raising to the power of.
This is what I have at the minute but it doesn't work. In what way doesn't it work? Please let us know the actual error you're getting. For your pasted code, Java syntax is much more rigid than math syntax. See here for a reference on Java operators. In particular, in math notation, multiplication is implied when you put two things next to each other. That's not true of Java. You need to explicitly use the multiplication operator. EDIT: It also seems you need to define k and ans unless they're instance variables with definitions you haven't included with your code snippet. If you haven't programmed in Java I'd strongly recommend reading some reference material. There are docs on the official Oracle site here More on reddit.com
Videos
08:11
Javaโs Math.pow() Method Explained - YouTube
Java Math.pow
04:15
Math.pow Java Exponents Tutorial #21
04:50
Power of a Number in Java || Explained using loop and Math.pow() ...
06:33
Java Program #32 - Calculate the Power of a Number in Java - YouTube
04:15
Math.pow Java Exponents Tutorial #21 - YouTube
W3Schools
w3schools.com โบ java โบ ref_math_pow.asp
Java Math pow() Method
System.out.println(Math.pow(2, ...ln(Math.pow(8, -1)); System.out.println(Math.pow(10, -2)); ... The pow() method raises a number to the power of another number....
W3Schools
w3schools.com โบ jsref โบ jsref_pow.asp
W3Schools.com
The Math.pow() method returns the value of x to the power of y (xy). let a = Math.pow(0, 1); let b = Math.pow(1, 1); let c = Math.pow(1, 10); let d = Math.pow(3, 3); let e = Math.pow(-3, 3); let f = Math.pow(2, 4); Try it Yourself ยป ยท Math.pow() ...
Codecademy
codecademy.com โบ docs โบ java โบ math methods โบ .pow()
Java | Math Methods | .pow() | Codecademy
June 23, 2025 - The Math.pow() method in Java is a static method that calculates the value of a base number raised to the power of an exponent. It performs exponentiation operations by taking two double parameters and returning the result as a double value.
Top answer 1 of 10
168
^ 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.
2 of 10
48
we can use
Math.pow(2, 4);
this mean 2 to the power 4 (2^4)
answer = 16
GeeksforGeeks
geeksforgeeks.org โบ java โบ calculating-the-power-of-a-number-in-java-without-using-math-pow-method
Calculating the Power of a Number in Java Without Using Math pow() Method - GeeksforGeeks
January 22, 2026 - Recursively calculate power(base, exponent/2) once and square it.
Programiz
programiz.com โบ java-programming โบ examples โบ power-number
Java Program to Calculate the Power of a Number
In this program, we use Java's Math.pow() function to calculate the power of the given base.
LinkedIn
linkedin.com โบ pulse โบ mathpow-method-java-example-ankitaa-panpatil-ouycf
Math.pow() Method in Java with Example
We cannot provide a description for this page right now
Carmatec
carmatec.com โบ home โบ java math.pow() explained: the java power function
Java Math.pow() Explained: The Java Power Function
January 7, 2026 - A negative base with a non-integer exponent typically returns NaN (e.g., Math.pow(-4, 0.5) โ square root of negative). Bases of magnitude greater than 1 raised to +Infinity return +Infinity. Bases between 0 and 1 raised to +Infinity return +0.0. Overflow results in +Infinity or -Infinity; underflow results in +0.0 or -0.0. ... java System.out.println(Math.pow(Double.NaN, 5)); // NaN System.out.println(Math.pow(-4, 0.5)); // NaN System.out.println(Math.pow(0, 0)); // 1.0 System.out.println(Math.pow(2, Double.POSITIVE_INFINITY)); // Infinity
Tutorialspoint
tutorialspoint.com โบ java โบ number_pow.htm
Java Math.pow() Method
This method returns the value of the first argument raised to the power of the second argument. public class Test { public static void main(String args[]) { double x = 11.635; double y = 2.76; System.out.printf("The value of e is %.4f%n", Math.E); ...
Naukri
naukri.com โบ code360 โบ library โบ math-pow-function-in-java
Math pow() Function in Java - Naukri Code 360
Almost there... just a few more seconds