Wednesday 9 October 2013

Program to Calculate area of Circle and demonstrate use of Math.pow()

//Program to Calculate area of Circle and demonstrate use of Math.pow()
//Developed by Ahlam Ansari

import java.util.*;
import java.io.*;

class SimpleArea
{
    public static void main (String ahlam[])
    {
        int radius;
        float circleArea;
        final float pi=3.14f;
        Scanner scan = new Scanner( System.in );
        System.out.println( "Enter the RADIUS of the circle");
        radius=scan.nextInt();
        circleArea=pi*(float)Math.pow(radius,2);
        System.out.println("The Area of Circle is "+ circleArea);
    }
}

/*

C:\Users\Ahlam\Google Drive\OOPM\Programs>java SimpleArea
Enter the RADIUS of the circle
2
The Area of Circle is 12.56

*/

No comments:

Post a Comment