Area of circle java

Hey guys!! Welcome to flower brackets. Today we are going to learn area of circle java.

Area of Circle Java

Decades ago we have seen and learnt area of circle in our school in geometry class.

Also Read – circumference of a circle in java

Well, in the below java program user enters radius as input. Next we use area of circle formula. Here’s the code and output of java program,

// area = pi * r * r where r is the radius of a circle 

import java.util.Scanner;

public class AreaOfCircleDemo 
{
   public static void main(String[] args) 
   {
      int radius;
      double pi = 3.14, area;
      Scanner sc = new Scanner(System.in);
      System.out.print("Please enter radius of circle : ");
      radius = sc.nextInt();
      area = pi * radius * radius;
      System.out.println("Area of circle : " + area);
      sc.close();
   }
}

Output:
Please enter radius of circle : 5
Area of circle : 78.5

Related Posts