-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCircleOperations.java
More file actions
28 lines (20 loc) · 854 Bytes
/
CircleOperations.java
File metadata and controls
28 lines (20 loc) · 854 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
import java.util.Scanner;
public class CircleOperations {
public static void main(String[] args) {
// Find circumference, area, and volume of a circle
Scanner scanner = new Scanner(System.in);
double radius;
double circumference;
double area;
double volume;
System.out.print("Enter the radius of the circle: ");
radius = scanner.nextDouble();
circumference = 2 * Math.PI * radius;
area = Math.PI * Math.pow(radius, 2);
volume = (4.0 / 3.0) * Math.PI * Math.pow(radius, 3);
System.out.printf("The circumference of a circle is: %.1fcm\n", circumference);
System.out.printf("The area of the circle is: %.1fcm²\n", area);
System.out.printf("The volume of the circle is: %.1fcm³\n", volume);
scanner.close();
}
}