Showing posts with label compute the area of the circle in java. Show all posts
Showing posts with label compute the area of the circle in java. Show all posts

Saturday, October 15, 2016

Compute the Area of the Circle in Java

Here is one of the oldest code in Java when I start learning how to program on it to compute the area of the circle in this example I am still using buffered reader in order to accept input values from the user.

Add me at Facebook my addressis jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 


My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 

My mobile number here in the Philippines is 09173084360.


Program Listing

import java.io.*;

public class area_circle {

public static void main(String [] args) throws Exception
{
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
int radius=0;
double pi, area;
System.out.println("Compute Area of a Circle\n");
System.out.print("Enter a value for radius: ");
radius = Integer.parseInt(input.readLine());
pi = 3.1416;
area = (pi * (radius * radius));
System.out.println("\nThe value for radius is: " + radius);
System.out.println("\nThe value for pi is: " + pi);
System.out.println("\nThe area of a circle is: " + area + "\n\n\n" );
System.out.println("\n\n\n" );
System.out.println("End of Program" );
}
}