1 public class SimpleCircle {
2
3 public static void main(String[] args) {
4
5 SimpleCircle circle1 = new SimpleCircle();
6 System.out.println("The area of the circle of radius "
7 + circle1.radius + " is " + circle1.getArea());
8
9
10 SimpleCircle circle2 = new SimpleCircle(25);
11 System.out.println("The area of the circle of radius "
12 + circle2.radius + " is " + circle2.getArea());
13
14
15 SimpleCircle circle3 = new SimpleCircle(125);
16 System.out.println("The area of the circle of radius "
17 + circle3.radius + " is " + circle3.getArea());
18
19
20 circle2.radius = 100;
21 System.out.println("The area of the circle of radius "
22 + circle2.radius + " is " + circle2.getArea());
23 }
24
25 double radius;
26
27
28 SimpleCircle() {
29 radius = 1;
30 }
31
32
33 SimpleCircle(double newRadius) {
34 radius = newRadius;
35 }
36
37
38 double getArea() {
39 return radius * radius * Math.PI;
40 }
41
42
43 double getPerimeter() {
44 return 2 * radius * Math.PI;
45 }
46
47
48 void setRadius(double newRadius) {
49 radius = newRadius;
50 }
51 }