Showing posts with label calculating area of circle. Show all posts
Showing posts with label calculating area of circle. Show all posts

Thursday, 13 June 2013

program for calculating area of circle in java

import java.io.*;
class simple_area_circle
{
    public static void main(String args[])
    {
        try
        {
            int r;
            float pie=3.14f,a;
            DataInputStream cin=new DataInputStream(System.in);
            System.out.println("Enter a radius to calculate area of circle");
            r=Integer.parseInt(cin.readLine());
            a=r*r*pie;
            System.out.println("area of circle with radius "+r+" is = "+a);
        }
        catch(Exception e)
        {
            System.out.println("Wrong data");
        }
    }
}