Here is a java Program to find the area and circumference of a circle. Given the radius of a circle, circumference and area of circle, can be calculated using below mentioned formula. First of all, we will take the radius of circle as input form user and then print the area and circumference of circle on screen.
- Circumference of Circle = 2 x PI x Radius
- Area of Circle = PI X Radius X Radius
Java program to calculate calculate and area of circle
package com.tcc.java.programs; import java.util.*; public class CircleArea { public static void main(String[] args) { double radius, area, circumference; Scanner in = new Scanner(System.in); System.out.println("Enter Radius of Circle:"); radius = in.nextDouble(); // Calculate area and circumference of circle area = Math.PI * radius * radius; circumference = 2 * Math.PI * radius; System.out.println("Area of Circle : " + area); System.out.println("Circumference of Circle : " + circumference); } }Output
Enter Radius of Circle: 3 Area of Circle : 28.274333882308138 Circumference of Circle : 18.84955592153876
Recommended Posts