how do I input "Square root of" Java?
How do input :
The square root of (vertical pixels^2+Horizontal pixels^2) in Java?
You can use
Math.sqrt() for that. BTW, to square a number, you have to use
^ is reserved for
double verticalPixels // = ...; double horizontalPixels // = ...; System.out.println("Square Root of Positive Number: " + Math.sqrt(Math.pow(verticalPixels, 2) + Math.pow(horizontalPixels, 2));
to input in java, you can do (I think):
Scanner sc=new Scanner(System.in);
here are some websites on input that can help you:
for the square root:
i found this:
The java.lang.Math.sqrt() returns the square root of a value of type double passed to it as argument. If the argument is NaN or negative, then the result is NaN. If the argument is positive infinity, then the result is positive infinity. If the argument passed is positive zero or negative zero then the result will be same as that of the argument.