- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiplicationTable.java
More file actions
Latest commit
26 lines (23 loc) · 903 Bytes
/
Copy pathMultiplicationTable.java
File metadata and controls
26 lines (23 loc) · 903 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
packageweek01.basic;
importjava.util.Scanner;
publicclassMultiplicationTable {
publicstaticvoidmain(String[] args) {
// 5단계(기초): 구구단 출력하기
// 문제: 사용자로부터 2에서 9 사이의 숫자를 입력받아 해당하는 단의 구구단을 출력하는 프로그램을 작성하세요.
// 힌트: for문, 변수, input, 출력
System.out.println("<구구단 출력하기>");
Scannerscanner = newScanner(System.in);
System.out.println("숫자를 입력하세요.>");
intnum = scanner.nextInt();
while(num<2||num>9) {
System.out.println("숫자를 잘못 입력하셨습니다.");
System.out.println("2~9 사이의 숫자를 입력해주세요.>");
num = scanner.nextInt();
}
System.out.println("<"+num+"단>");
for(inti=1; i<=9; i++) {
System.out.println(num+"*"+i+"="+(num*i));
}
scanner.close();
}
}