In this java program we are going to calculate area and circumference of a circle. For this we will use below Formula to calculate area and circumference of a circle.
Area of circle = PI*Radius*radius; Circumference of circle=2*PI*radius
Java Program to Calculate Area And Circumference of Circle
import java.util.Scanner;
class Circle { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.print("Enter the radius of Circle: "); double radius = sc.nextDouble(); /* Area of Circle = PI*radius*radius */ double area = Math.PI * (radius * radius); System.out.println("Area of circle is : " + area); /* Circumference of Circle = 2*PI*radius */ double circumference= Math.PI * 2*radius; System.out.println( "Circumference of the circle is: " +circumference) ; } }
Output:-
