Write a java program to find area of circle

 EX: Write a java program to find area of circle. How to write a java program to find area of circle. Java program to find area of circle.


Logic to find area of circle: 

To find area of circle we can use formula of area of circle which is π r² .

Here, r is radius and value of pi is 3.14. 

So in program we can write as  area = 3.14*radius*radius;


Program to find area of circle:

import java.util.Scanner;

public class AreaofCircle {


    public static void main(String[] args) {

        int radius;
        double area;

        Scanner sc = new Scanner(System.in); 

        System.out.println("Enter the radius : ");
        radius = sc.nextInt();

        area = 3.14*radius*radius;//here, 3.14 is a value of pi...
        System.out.println("Area of circle is : " +area);
        
    }
}
Above java program shows the following output:

Enter the radius: 55
Area of circle is : 9498.5 



No comments:

Post a Comment

If you have any doubts, please discuss here...👇