Write a Java program to calculate Area of Circle
Problem Statement:
Write a Java program to calculate the Area of the Circle. On this page, we will write a java program to calculate the area of the circle. Before writing the program we will analyze the IPO of the program.
Input
The radius of the circle
Process
Area of Circle = pi * r * r
Output
Area of Circle
Java Program:
import java.util.Scanner; /************************************************** * CircleDemo.java * @program : Area of Circle * @web : www.TestingDocs.com * @author : * @version : 1.0 **************************************************/ public class CircleDemo { //main public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); double radius, areaCircle; System.out.print("Enter Radius of the Circle := "); radius = keyboard.nextDouble(); // formula = pi r square areaCircle = Math.PI*radius*radius; System.out.println("Area of Circle = "+ areaCircle); keyboard.close(); } // end main } // end CircleDemo
Sample Output:
Enter Radius of the Circle := 3.5
Area of Circle = 38.48451000647496