Showing posts with label java basic programs. Show all posts
Showing posts with label java basic programs. Show all posts

Monday, 4 August 2014

Java Code to find the Area of Circle

Area of a Circle Using Java

A Java program to accept the radius of a Circle from user and calculate the area.


//A small java program to calculate the area of a circle
import java.util.Scanner;

public class JavaCircleArea {

    public static void main(String args[])
   {
      int radius;
      System.out.println("Enter the Radius of the Circle ");

      Scanner in = new Scanner(System.in);
      radius = in.nextInt(); 

      double areaCircle = Math.PI*radius*radius;
      System.out.println("Area of the Circle = "+areaCircle);
   }
    
}


Output:


Enter the Radius of the Circle 
3
Area of the Circle = 28.274333882308138