Ask Question
4 September, 23:22

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.

+2
Answers (1)
  1. 5 September, 01:31
    0
    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.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Assume there is a variable, h already assigned a positive integer value. Write the code necessary to assign its square to the variable g. ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers