-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray_Test3.java.bak
More file actions
44 lines (35 loc) · 1.13 KB
/
Array_Test3.java.bak
File metadata and controls
44 lines (35 loc) · 1.13 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
35
36
37
38
39
40
41
42
43
44
import java.util.*;
class Array_Test3 {
public static void main(String ar[]) {
Scanner sc=new Scanner(System.in);
// 1번 문제. 키보드에서 숫자 2개를 입력받아 어떤수가 큰지 출력
System.out.println("1번 문제 ♥");
int a[]=new int[2];
for (int i=0; i<a.length; i++) {
System.out.print("정수를 입력하세요. : ");
a[i]=sc.nextInt();
}
if (a[0]>a[1]) {
System.out.println("방 a[0]안에 있는 수 "+a[0]+"이(가) 방 a[1]안에 있는 수 "+a[1]+"보다 더 큽니다.");
}
else if (a[0]<a[1]) {
System.out.println("방 a[0]안에 있는 수 "+a[0]+"이(가) 방 a[1]안에 있는 수 "+a[1]+"보다 더 작습니다.");
}
else {
System.out.println("방 a[0]안에 있는 수 "+a[0]+", 방 a[1]안에 있는 수"+a[1]+" ==> 같습니다.");
}
System.out.println();
// 2번 문제. 키보드에서 정수를 10개 입력받아 배열에 저장하고 이 정수중에서 3의 배수만 골라 화면에 출력
System.out.println("2번 문제 ♥");
int b[]=new int[10];
for (int i=0; i<b.length; i++) {
System.out.print("정수를 입력하세요. : ");
b[i]=sc.nextInt();
}
for (int i=0; i<b.length; i++) {
if (b[i]%3==0) {
System.out.println(b[i]);
}
}
}
}