-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCircle1.java
More file actions
28 lines (22 loc) · 779 Bytes
/
Copy pathCircle1.java
File metadata and controls
28 lines (22 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public class Circle1 {
public static void main(String[] args) {
Circle1 circle1=new Circle1();
System.out.println("The area of the circle of radius "+circle1.radius+" is "+circle1.getArea());
Circle1 circle2=new Circle1(25);
System.out.println("The area of the circle of radius "+circle2.radius+" is "+circle2.getArea());
Circle1 circle3=new Circle1(125);
System.out.println("The area of the circle of radius "+circle3.radius+" is "+circle3.getArea());
circle2.radius=100;
System.out.println("The area of the circle of radius "+circle2.radius+" is "+circle2.getArea());
}
double radius;
Circle1(){
radius=1.0;
}
Circle1(double newRadius){
radius=newRadius;
}
double getArea() {
return radius*radius*Math.PI;
}
}