-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava141_Scanner.java
More file actions
52 lines (38 loc) · 920 Bytes
/
Copy pathJava141_Scanner.java
File metadata and controls
52 lines (38 loc) · 920 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package java0907_api;
import java.util.Scanner;
/*
단 입력:5
5 X 1 = 5
------------------------
5 X 9 = 45
계속하시겠습니까? (종료 : n, 계속: 아무키)a
단 입력:3
3 X 1 = 3
-------------------------
3 X 9 = 27
계속하시겠습니까? (종료 : n, 계속: 아무키)n
프로그램 종료
*/
public class Java141_Scanner {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
boolean o = true;
while (o) {
System.out.print("단 입력:");
int dan = sc.nextInt();
danOp(dan);
System.out.print("계속하시겠습니까? (종료 : n, 계속: 아무키)");
String res = sc.next();
if (res.equals("n")) {
System.out.println("프로그램 종료");
o = false;
}
}
sc.close();
}
public static void danOp(int dan) {
for (int i = 1; i < 10; i++) {
System.out.printf("%d X %d = %d\n", dan, i, dan * i);
}
}
}