Jan 13, 2022

Java Program To Calculate Area Of Circle - Java Program With Example

Write Java Program To  Calculate Area Of Circle. In This Post We Share A Java Program Code For Calculate  Area Of Circle Which Entered By User And Show Output On Screen After Compile Program.


package com.androidpro.in;

import
java.io.BufferedReader;
import
java.io.InputStreamReader;
import
java.util.Scanner;

public class
Main {

   
public static void main(String[] args)
    {
       
int radius = 3;
        
System.out.println("The radius of the circle is " + radius);
       
/*
         * Area of a circle is pi * r * r where r is a radius of a circle.
         */
        // NOTE : use Math.PI constant to get value of pi
       
double area = Math.PI * radius * radius;
       
System.out.println("Area of a circle is " + area);
   
}



}

 

Output

The radius of the circle is 3

Area of a circle is 28.274333882308138

Process finished with exit code 0

Whatsapp Button works on Mobile Device only