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
A data flow cannot go directly back to the same process it leaves. There must be at least ________ other process(es) that handle
Flauer [41]

Answer:

Answer is A. One.

Refer below.

Explanation:

A data flow cannot go directly back to the same process it leaves. There must be at least one other process that handle(s) the data flow, produce(s) some other data flow, and return(s) the original data flow to the beginning process.

3 0
3 years ago
Press ____ to select the entire worksheet.<br> F1<br> F4<br> ALT+A<br> CTRL+A
andreev551 [17]
<span>The answer is CTRL + A, this selects whole worksheet (A means all). In computing, a Control key is a transformer key which, when pushed in combination with one more key, achieves a singular operation (for example, Ctrl + A; like the Shift key, the Control key infrequently achieves any purpose when pushed by itself.</span>
5 0
3 years ago
What is the purpose of the property, transition-timing-function?
oksano4ka [1.4K]

Answer:

It changes the speed at different stages of the transition.

Explanation:

HTML is an acronym for hypertext markup language and it is a standard programming language which is used for designing, developing and creating web pages.

Generally, all HTML documents are divided into two (2) main parts; body and head. The head contains information such as version of HTML, title of a page, metadata, link to custom favicons and CSS etc. The body of the HTML document contains the contents or informations that a web page displays.

Basically, the purpose of the property, transition-timing-function is that It changes the speed at different stages of the transition. Thus, it states the values between the beginning and ending of a transition are calculated over its duration.

4 0
3 years ago
You need to secure your wireless network. which security protocol would be the best choice
natka813 [3]
Changing the password. whenever you change the password of your router, it disconnects all current devices, including ones you don't want to be connected. from there, reconnect the devices you want on the network and then you are done!
7 0
3 years ago
Here it is crews my profile pic
Murrr4er [49]
It looks niceee
Also can you mark me brainlyest for extra points
7 0
3 years ago
Read 2 more answers
Other questions:
  • Two electronics technicians are looking at the piece of testing equipment shown in the figure above. Technician A says that this
    8·2 answers
  • Texture fills are available to add as a slide background true or false
    7·2 answers
  • What does the headgear of a mine do
    6·2 answers
  • An adiabatic capillary tube is used in some refrigeration systems to drop the pressure of the refrigerant from the condenser lev
    15·1 answer
  • What do you think about the future of computers?​
    14·1 answer
  • What is the best option for sharing Word documents on a Microsoft network because it provides finer degrees of versioning contro
    6·1 answer
  • State the functions of all the parts of the computer​
    14·1 answer
  • Light the<br> Spark hop<br> Answer if ur a baddie;)))
    9·2 answers
  • How are digital and analog data similar? How are they different?
    15·1 answer
  • Bad Directions You are driving to your friend’s house and are using your smartphone for directions. While approaching your desti
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!