Question: java programming 5.Java has many built-in math functions available to us in the Math library. However, sometimes its worthwhile practice to implement these using our

java programming

5.Java has many built-in math functions available to us in the Math library. However, sometimes its worthwhile practice to implement these using our own smarts!

Write a method called squareRoot() that takes an integer and returns an integer that is closest to its square root.

For example, if the method is given 36 then it should certainly return 6 (its proper square root).

However, if the method is given 38, it should return 6 (the integer closest to its square root).

If your method is given a negative integer as parameter, it should return -1.

Use proper method signature

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!