-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScannerExample.java
More file actions
32 lines (26 loc) ยท 901 Bytes
/
ScannerExample.java
File metadata and controls
32 lines (26 loc) ยท 901 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
package ch02.sec11;
import java.util.Scanner;
public class ScannerExample {
public static void main(String[] args) throws Exception {
Scanner scanner = new Scanner(System.in);
System.out.println("x ๊ฐ ์
๋ ฅ: ");
String strX = scanner.nextLine();
int x = Integer.parseInt(strX);
System.out.println("y ๊ฐ ์
๋ ฅ: ");
String strY = scanner.nextLine();
int y = Integer.parseInt(strY);
int result = x + y;
System.out.println("x + y: " + result);
System.out.println();
while (true) {
System.out.print("์
๋ ฅ ๋ฌธ์์ด: ");
String data = scanner.nextLine();
if (data.equals("q")) {
break;
}
System.out.println("์ถ๋ ฅ ๋ฌธ์์ด: " + data);
System.out.println();
}
System.out.println("์ข
๋ฃ");
}
}