The following method that returns the square root of n. c static double sqrt(long n)
In java with clear coding please, Thank you.


Program Approach:
1- As mentioned in the assignment, implement the sqrt method.
2- Need to import the Math package and the util package.
3- Util package is used to create the object of the scanner class.
4- Scanner class used to take the input from a user.
5- Create the method as mentioned in the assignment sqrt() with one parameter.
6- Invoke that method from the main method.
7- Prompt a message to take input from a user.
8- Create a variable as a number to store the value entered by a user.
9- Pass that value to the sqrt() method as a parameter.
10- That method will return the sqrt value and display the output on the screen.
11- Please check the following complete implementation of the sqrt() method and output screenshot.
Step by step
Solved in 3 steps with 1 images









