Assume there is a variable, h already assigned a positive integer value. Write the code necessary to assign its square to the variable g. For example, if h had the value 8 then g would get the value 64.

Respuesta :

ijeggs

Answer:

public class num10 {

   public static void main(String[] args) {

       int h =8;

       double g = Math.pow(h,2);

       System.out.println("The Squared value of "+h+" is "+g);        

   }

}

Explanation:

Using Java programming Language, As stated in the question, h is declared as an int and assigned the value of 8.

a variable g is declared and assigned the square of h using java's power method in Math class

The squared value is then outputed to the console.

Q&A Education