6. JAVA Program to find Area and Circumference of a circle.
How does this program work?
- In this program you will learn about how to calculate Area and Circumference of a circle.
- This program requires the user input to enter the Radius of a circle.
- This program perform mathematical calculation and display the result using java.
Here is the code
//Area and Circumference of Circle
import java.util.Scanner;public class Area
{
public static void main(String args[])
{
int r ;
double area,circumference ,pi=3.14;
System.out.println("Enter Radius of Circle : " );
Scanner obj=new Scanner(System.in);
r=obj.nextInt();
// Area of a circle is pi*radius*radius
area=pi*r*r;// Area of a circumference is 2*Pi*radius
circumference=2*pi*r;System.out.println(" Area of the circle is: "+area );
System.out.println(" Circumference of the circle is: "+circumference);
}
}