^ 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.
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
July 25, 2025 - Almost there... just a few more seconds