Function that takes the radius of a circle as an argument and returns its area in java.
import java.util.*;
class Circle
{
public static double circleArea(double x)
{
double ar;
ar=3.14*x*x;
return ar;
}
public static void main(String[] args)
{
Scanner sc =new Scanner(System.in);
System.out.print("enter the radius=");
double r=sc.nextDouble();
double area=circleArea(r);
System.out.println("the area of circle is = "+area);
}
}
■》Output->
enter the radius=10
the area of circle is = 314.0
Comments
Post a Comment