class MyClassCircle {
private double radius;
MyClassCircle(double radius) {
this.radius = radius;
}
public double getArea() {
return Math.PI * radius * radius;
}
}
class GetAreaDemo {
public static void main(String [] args) {
MyClassCircle circle = new MyClassCircle(5.6);
System.out.println("Area of the circle with radius 5.6 equal to " + cicle.getArea());
}
}
1. List down the variables you used and it's uses in the program.
2. What is the formula for getting the area of the circle, based on the codes?
1. List down the variables you used and it's uses in the program.
Answer:
1. double radius
2. MyClassCircle circle
2. What is the formula for getting the area of the circle, based on the codes?
Answer:
Area= Math.PI * radius * radius
Comments
Leave a comment