Respuesta :
Answer:
The program to this question can be given as:
Program:
import java.lang.*;
class root //define class
{
int i; //define variable
public void Squareroot()
//define function
{
System.out.println("Number\tsquare root"); //print message.
for(i=1;i<=25;i++) //use for loop
{
System.out.println(i+"\t"+Math.sqrt(i)); //print value and using square root function
}
}
}
public class Main //define class
{
public static void main(String[] ar) //define main method
{
root ob= new root(); //create class object
ob.Squareroot();
calling function
}
}
output:
Number Square Root
1 1.0
2 1.414
3 1.732
4 2.0
5 2.236
.
.
.
24 4.898
25 5.0
Explanation:
In the above program firstly we declare a class that is root. In this class, we declare a variable(i) and function(Squareroot). In the function, we define a loop that uses the variable to print all the values. In the loop, we use the math square root function that is sqrt. This function is bind in java package i.e java.lang.*; This function returns square root that's value type is double. Then we define a main class in the main class we define the main function in the main function we create a root class object and call the function.