|
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
|
package day_06;
public class Day06Ex03 {
public static void main(String[] args) {
Scanner scanner= new Scanner(System.in);
// 주소를 저장하는 배열을 선언한다.
// 주소 3개를 Scanner로 입력받아 배열에 저장하고 내용을 출력한다.
// 주소 문자열의 길이를 함께 출력한다.
String[] address= new String[3] ;
System.out.println("시를 입력하세요");
address[0] = scanner.nextLine();
System.out.println("구를 입력하세요");
address[1] = scanner.nextLine();
System.out.println("상세 주소를 입력하세요");
address[2] = scanner.nextLine();
for (int i=0; i<address.length; i++) {
System.out.print(" "+address[i]);
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
package day_06;
public class Day06Ex04 {
static Scanner scanner= new Scanner(System.in);
public static void main(String[] args) {
String[] student= new String[2];
//NullPoiter - 객채의 주소가 없다. (객체가 만들어지지 않았다.)
System.out.println("Hello");
System.out.print("성명 입력: ");
student[0]= scanner.nextLine();
System.out.print("주소 입력: ");
student[1]= scanner.nextLine();
System.out.println(student[0] + ":" + student[1]);
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
|
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
|
package java1;
// 양수 5개를 입력받아 배열에 저장하고, 제일 큰 수를 출력하는 프로그램을 작성하여라,
public class test {
public static void main(String[] args) {
Scanner scanner= new Scanner(System.in);
int[] intarr= new int[5];
int max= 0;
System.out.println("양수 다섯개를 입력하세요");
for(int i=0; i<intarr.length; i++) {
intarr[i]= scanner.nextInt();
if(intarr[i]>max)
max=intarr[i];
}
System.out.println("가장 큰 수는" + max + "입니다.");
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |