Program to find the circumference of circle using function in java.
import java.util.*;
public class function {
public static double calculateCircumference(int r){
return(2*3.14*r);
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("enter the radius of circle=");
int r=sc.nextInt();
System.out.print("the circumference of circle is="+calculateCircumference(r));
}
}
■》Output->
enter the radius of circle= 4
the circumference of circle is= 25.12
Comments
Post a Comment