//Program to Calculate Area of Circle using Classes and Objects
//Developed by Ahlam Ansari
import java.util.*;
import java.io.*;
class Area
{
int radius;
float circleArea;
final float pi=3.14f;
void inputData()
{
Scanner scan = new Scanner( System.in );
System.out.println( "Enter the RADIUS of the circle");
radius=scan.nextInt();
}
void calculateArea()
{
circleArea=pi*(float)Math.pow(radius,2);
}
void displayArea()
{
System.out.println("The Area of Circle is "+ circleArea);
}
}
class MainArea
{
public static void main (String ahlam[])
{
Area a= new Area();
a.inputData();
a.calculateArea();
a.displayArea();
}
}
/*
C:\Users\Ahlam\Google Drive\OOPM\Programs>javac MainArea.java
C:\Users\Ahlam\Google Drive\OOPM\Programs>java MainArea
Enter the RADIUS of the circle
2
The Area of Circle is 12.56
*/
//Developed by Ahlam Ansari
import java.util.*;
import java.io.*;
class Area
{
int radius;
float circleArea;
final float pi=3.14f;
void inputData()
{
Scanner scan = new Scanner( System.in );
System.out.println( "Enter the RADIUS of the circle");
radius=scan.nextInt();
}
void calculateArea()
{
circleArea=pi*(float)Math.pow(radius,2);
}
void displayArea()
{
System.out.println("The Area of Circle is "+ circleArea);
}
}
class MainArea
{
public static void main (String ahlam[])
{
Area a= new Area();
a.inputData();
a.calculateArea();
a.displayArea();
}
}
/*
C:\Users\Ahlam\Google Drive\OOPM\Programs>javac MainArea.java
C:\Users\Ahlam\Google Drive\OOPM\Programs>java MainArea
Enter the RADIUS of the circle
2
The Area of Circle is 12.56
*/
No comments:
Post a Comment