1) a round class (Circle), include:
Properties: circle radius radius; Constant PI,
Methods: the constructor; Calculating the area of area (); For generating circumference method (), 2) the main class (X4_3_1), include:
Main method main (), in the main method to create the circle and initializes the object of the class c1 and 2, cl, 2 the radius of the radius of 100 to 200, and then shows two circles of area and perimeter, respectively,
CodePudding user response:
Simple do ahCodePudding user response:
Public class Circle {
Private int the radius;
Public static final double PI=Math. PI;
Public Circle radius, (int) {
Enclosing the radius=radius;
}
Public int getRadius () {
Return the radius.
}
Public void setRadius radius, (int) {
Enclosing the radius=radius;
}
Public double area () {
Radius, return PI * * radius;
}
Public double generating () {
Return 2 * PI * radius;
}
Public static void main (String [] args) {
Circle c1=new Circle (100);
Circle the c2=new Circle (200);
System. The out. Println (" is the area of the circle c1: "+ c1. Area ());
System. The out. Println (" is the circumference of the circle c1: "+ c1. Generating ());
System. The out. Println (" the area of the circle c2: "+ c2. Area ());
System. The out. Println (" is the circumference of the circle c2: "+ c2. Generating ());
}
}