Java Program || Write a Java program to enter radius of a circle and find its diameter, circumference and area.||
Write a Java program to enter radius of a circle and find its diameter, circumference and area.
Solution :-
circumference = 2 * 3.14 * radius
area = 3.14 * radius * radius
{
public static void main(String args[])
{
int radius = 10;
double pi = 3.14;
double diameter,circumference,area;
diameter = 2 *radius;
circumference = 2 * pi * radius;
area = pi * radius * radius;
System.out.println("The diameter of the circle :-"+diameter);
System.out.println("The circumference of the circle :-"+circumference);
System.out.println("The area of the circle"+area);
}
}
Output :-
Dynamic :-
import java.util.*;
class circle
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter the radius :- ");
int radius = in.nextInt();
double pi = 3.14;
double diameter,circumference,area;
diameter = 2 *radius;
circumference = 2 * pi * radius;
area = pi * radius * radius;
System.out.println("The diameter of the circle :-"+diameter);
System.out.println("The circumference of the circle :-"+circumference);
System.out.println("The area of the circle"+area);
}
}
Output :-