import
java.util.Scanner;
class Circle {
double radius,area;
void setData(double x) {
radius=x;
}
void calculate() {
area=3.14*radius*radius;
System.out.println("Area is:
"+area);
}
}
class CircleEx
{
public static void main(String args[]) {
double x;
Scanner sc=new Scanner(System.in);
Circle c=new Circle();
System.out.print("Enter radius of
circle: ");
x=sc.nextDouble();
c.setData(x);
c.calculaute();
}
}
OUTPUT:
C:\jdk1.7.0\bin>java
CircleEx
Enter radius of
circle: 1
Area is: 3.14
No comments:
Post a Comment