-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJP11.java
More file actions
34 lines (31 loc) · 1.15 KB
/
JP11.java
File metadata and controls
34 lines (31 loc) · 1.15 KB
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
31
32
33
34
package jp;
import java.util.Scanner;
public class JP11 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int key = -1;
while (key != 0) {
System.out.println("Podaj promień");
int r = scanner.nextInt();
System.out.println("Co chcesz obliczyć: \n(1) Pole koła \n(2) Obwód koła \n(3) Powierzchnia sfery \n(0) Wyjście");
key = scanner.nextInt();
switch (key) {
case 1:
System.out.printf("Promień koła: %.2f \n", Math.PI * Math.pow(r, 2));
break;
case 2:
System.out.printf("Obwód koła: %.2f \n", 2 * Math.PI * r);
break;
case 3:
System.out.printf("Pole sfery: %.2f \n", (4 * Math.PI * Math.pow(r, 3) / 3));
break;
case 0:
System.out.println("Wyjście");
break;
default:
System.out.println("Błędny wybór!");
}
System.out.println("END");
}
}
}