-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimes.java
More file actions
36 lines (30 loc) · 863 Bytes
/
Times.java
File metadata and controls
36 lines (30 loc) · 863 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
31
32
33
34
import java.util.Scanner;
public class Times {
public static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args) {
times();
times();
times();
times();
}
public static void times() {
System.out.print("請輸入一個整數:");
int num = keyboard.nextInt();
if ((num % 2) == 0) {
if ((num % 3) == 0) {
System.out.println(num + "是2、3、6的倍數。");
}
else {
System.out.println(num + "是2的倍數。");
}
}
else {
if ((num % 3) == 0) {
System.out.println(num + "是3的倍數。");
}
else {
System.out.println(num + "都不是2、3、6的倍數。");
}
}
}
}