Java Area of a Circle Program is one of the simplest programs for the new java programmers. It is a sequential set of statements without any conditional or looping statements.
The program presented here as example reads the radius of the circle from the user and returns the area of the circle using the following formula.
Area of circle = pi * radius * radius where pi=22/7 (3.141)
Java Area of a Circle
Let’s see how the above formula is implemented in java program to find the area of the circle.
import java.util.Scanner; public class CircleArea { public static void main(String[] args) { Scanner scObj= new Scanner(System.in); //Read year value from user System.out.println("Enter the radius of the circle"); int intRadius = scObj.nextInt(); //declare and initialise variable int cirArea= intRadius*intRadius* 22/7; System.out.println(cirArea + " is area of a circle with radius="+intRadius); } }