QUESTION IMAGE
Question
jump to level 1
compute: answer = \sqrt{g*h}
ex: if the input is 4.00 9.00, then the output is:
answer = 6.00
public class mathmethods {
public static void main(string args) {
scanner scnr = new scanner(system.in);
double g;
double h;
double answer;
g = scnr.nextdouble();
h = scnr.nextdouble();
/ your code goes here /
system.out.printf(\answer = %.2f\
\, answer); // outputs answer with 2 decimal places
}
}
Step1: Read input values
Let's assume the input values for \(g\) and \(h\) are read as per the code.
Step2: Calculate product
First, calculate the product of \(g\) and \(h\), i.e., \(product = g\times h\).
Step3: Calculate square - root
Then, find the square - root of the product. \(answer=\sqrt{product}\).
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
The Java code to complete the calculation in line 12 would be: