-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCircle.java
More file actions
30 lines (27 loc) · 874 Bytes
/
Copy pathCircle.java
File metadata and controls
30 lines (27 loc) · 874 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
29
30
import java.util.Scanner;
public class Circle {
double radiusInMm;
Circle(double radiusInMm) {
this.radiusInMm = radiusInMm;
}
double getCircumference() {
return 2 * radiusInMm * Math.PI;
}
double getArea() {
return Math.PI * Math.pow(radiusInMm,2);
}
@Override
public String toString() {
return "Circle props:Radius in mm:" + radiusInMm
+",Circumference in mm:" + getCircumference()
+",Area in mm2: " + getArea();
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Welcome to the world of Circle\n");
System.out.println("please enter your radius:");
double radius = input.nextDouble();
Circle circle = new Circle(radius);
System.out.println(circle);
}
}