Java program to calculate Area of Circle
Java program to calculate the Area of Circle
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.
IPO Chart
Input: The data, resources, etc that enter the system.
Process: The actions, operations, or calculations that transform inputs into outputs by the program.
Output: The final results, and outputs produced by the system.
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
Sample output of the program is as follows:
Enter Radius of the Circle := 3.5
Area of Circle = 38.48451000647496
Â
Screenshot
Screenshot of the program in the IDE.
Java Tutorials
Java Tutorial on this website:
For more information on Java, visit the official website :