Ask Question
27 April, 21:09

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.

+5
Answers (1)
  1. 27 April, 21:55
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers