1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
mihalych1998 [28]
3 years ago
15

Complete the method, isPerfectSquare(). The method takes in a positive integer, n. It returns a boolean that is true if n is a p

erfect square, false otherwise. A perfect square is an integer whose square root is also an integer. You may assume that n is a positive integer.
Hint: find the square root of n, cast it to an int value, then square it and compare this square to n.
Starter code:-
public class Square {
public static boolean isPerfectSquare(int n) {
//TODO: complete this method
}
}
Computers and Technology
1 answer:
ratelena [41]3 years ago
7 0

Answer:

  1. public class Square {
  2.    public static boolean isPerfectSquare(int n){
  3.        int sqrt_n = (int) Math.sqrt(n);
  4.        if(sqrt_n * sqrt_n == n ){
  5.            return true;
  6.        }else{
  7.            return false;
  8.        }
  9.    }
  10. }

Explanation:

Firstly, use sqrt method from Math package to calculate the square root of input n (Line 3). Cast the result to integer and assign it to sqrt_n variable.

Next, square the sqrt_n and check if it is equal to input n (Line 4). If so, return true, if not, return false (Line 4-8).

You might be interested in
Please help explain this calculator code.
goblinko [34]

Answer:

i dont know ask the calc to do it. hehe

Explanation:

7 0
3 years ago
Word-processing,spreadsheets, databases, and desktop publishing are all types of _______?
vichka [17]

Answer:

software

Explanation:

5 0
3 years ago
Read 2 more answers
2. Identify the diagram and define it.<br>13. What are pollen grains ?<br>4. What is an embryo?​
Virty [35]

Answer:

2. I can't help you with this question because i can't see the diagram

13.Pollen grains are microscopic bodies that have the male reproductive cell of the plant.

4. An Embryo is an organism in its early stage of development.

Explanation:

2. I can't help you with this question because i can't see the diagram

13.Pollen grains are microscopic bodies that have the male reproductive cell of the plant.

4. An Embryo is an organism in its early stage of development.

7 0
3 years ago
A highly available server is available what percentage of the time?
Verdich [7]

Answer:

b. 99.99%

Explanation:

<u>High available server</u>

A typical dedicated server is a strong machine linked to a high-speed Internet connection and located in a state-of - the-art distant data center or optimized information warehouse.

A dedicated High Availability Server is an sophisticated system with redundant network,redundant power supplies and backups to ensure maximum up-time.

5 0
3 years ago
Does virtualization impact the design of programs on behalf of the process/threading model?
zaharov [31]

Answer:

 Virtualization is the process which refers to the isolating the various computing resources that basically run without depend on the particular platform in the environment.

The virtualization basically allow the various application like software and hardware that mainly used to connect different types of server and storage applications.

The virtualization impact while designing the program is that it helps in the program execution process and also reducing the impact by using the hardware virtualization support in the system. The thread system also maintain the virtualization impact while designing.

7 0
4 years ago
Other questions:
  • In the client-server model, what is the primary protocol used for communication between a browser and Web server?
    10·1 answer
  • Which software application should be used to communicate in writing about an upcoming event?
    12·2 answers
  • What’s the best description of an opportunity cost
    5·1 answer
  • A phonebook typically lists the name, address, and telephone number of everyone living in an area. Write code defining a structu
    15·1 answer
  • When a person bullies someone using technology, it's called:
    9·2 answers
  • List two major problems that could be addressed by futuring.
    15·1 answer
  • What is the difference between spyware and adware?
    8·2 answers
  • Need the answer ASAP!!! I’ll mark brainliest if correct
    5·1 answer
  • What is meant by a control plane that is based on logically centralized control? In such cases, are the data plane and the contr
    8·1 answer
  • How to turn off microsoft teams message notifications
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!