write a Java program to calculate area of the circle - C C++ Java Programs - Examples

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Monday, March 2, 2015

write a Java program to calculate area of the circle



ALGORITHM:

Step 1: Read value of r.

Step 2: a = 3.14*r*r

Step 3: print area a.

Step 4: Stop

PROGRAM: import java.io.*; class clsarea

{

public static void main(String args[])throws IOException

{

BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); float r,a;
System.out.println("Enter the radius:"); r=Float.parseFloat(br.readLine()); a=3.14f*r*r;

System.out.println("Area is "+a);

}}

OUTPUT:

D:\JAVA>javac clsarea.java D:\JAVA>java clsarea Enter the radius:

10


Area is 314.0 D:\JAVA>

No comments:

Post a Comment