File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Difficult01/Question 2.19 Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java .util .Scanner ;
2
+
3
+ public class Circle {
4
+
5
+ private Scanner keyboardInput ;
6
+ private int circleRadius ;
7
+ private int circleDiameter ;
8
+ private double circleCircumference ;
9
+ private double circleArea ;
10
+
11
+ public Circle () {
12
+ keyboardInput = new Scanner (System .in );
13
+ System .out .println ("Enter the Circle's radius" );
14
+ circleRadius = keyboardInput .nextInt ();
15
+ circleDiameter = circleRadius *2 ;
16
+ circleCircumference = circleDiameter *Math .PI ;
17
+ circleArea = circleRadius *circleRadius *Math .PI ;
18
+
19
+ }
20
+
21
+
22
+ @ Override
23
+ public String toString () {
24
+ return String .format ("Circle Details\n Diameter: %d" +
25
+ "\n Circumference: %.3f\n Area: %.3f" ,
26
+ circleDiameter , circleCircumference , circleArea );
27
+ }
28
+
29
+ public static void main (String [] args ) {
30
+ Circle circle = new Circle ();
31
+
32
+ System .out .println (circle .toString ());
33
+
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments