Ask Question
11 April, 02:44

Write a boolean method that checks whether a given positive integer n is a perfect square. Use Math's sqrt and round methods to find the square root of n, round it, then square the result and compare with n. Do not use any iterations or recursion.

+4
Answers (1)
  1. 11 April, 06:43
    0
    In java ...

    public boolean checkSquare (int n) {

    int actualNumber = n;

    int squareRoot = (int) Math. sqrt (n);

    int squaredNumber = Math. pow (squareRoot, 2);

    if (squaredNumber==actualNumber) {

    return true;

    } else {

    return false;

    }

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a boolean method that checks whether a given positive integer n is a perfect square. Use Math's sqrt and round methods to find the ...” 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