목록java (69)
June is Combung
package week3; public class Day12_4 { public static void main(String[] args) { // 1단계 String str = "11/100/89"; // 문제 1) arr 배열에 각 점수를 저장하고, 총점 출력 // 정답 1) 200 String[] temp = str.split("/"); int total = 0; for (int i = 0; i < temp.length; i++) { total += Integer.parseInt(temp[i]); } System.out.println("문제1 : "); System.out.printf("총점은 %d \n", total); // 문제 2) scores 배열의 각 점수를 슬러시를 구분자로 하나의 문자열로..
package week3; public class Day12_3 { public static void main(String[] args) { // 문자 -> 숫자 char ch = 'a'; // 타입캐스팅 --> 강제 형변환 int aNum = (int) ch; System.out.println(aNum); // 97 double pi = 3.14; System.out.println((int) pi); ch = (char) (aNum + 1); System.out.println(ch); // b // 문자열 -> 숫자 String strNum = "10"; // (String)num int num = Integer.parseInt(strNum); System.out.println(num + 1); // ..
package week3; public class Day12_2 { public static void main(String[] args) { // 사용자에게 이름과 주민번호를 입력 받으세요 // 사용자의 주민번호를 통해서 나이를 계산해서 // 만나이를 출력 // 사용자가 여자인지 남자인지 주민등록 뒷번호를 통해서 출력 // 박연미 19901210-2123456 // 나이계산 // 박연미님은 30세 여자입니다 String name = "박연미"; // 0123456789 String jubun = "19951210-3123456"; // char year[]=new char[4]; String year = ""; for (int i = 0; i < 4; i++) { // year[i] = jubun.cha..
package week3; import java.util.Scanner; public class Day12_1 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); // Scanner sc = new Scanner(System.in); // 문자열은 배열이랑 똑같다 // int double boolean char // String 기본타입 자료형이 아니라 클래스다 String test0 = "hello"; System.out.println(test0); System.out.println("숫자를 입력하세요 "); int num0 = scan.nextInt(); System.out.println("num = " +..
package week3; import java.util.Scanner; public class Day11_5 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int[] arr = { 10, 20 }; boolean run = true; while (run) { for (int i = 0; i < arr.length; i++) { System.out.print(arr[i] + " "); } System.out.println(); System.out.println("[1]추가"); System.out.println("[2]삭제(인덱스)"); System.out.println("[3]삭제(값)"); System..
package week2; public class Day11_4 { public static void main(String[] args) { /* * int num = 10; // new int[5] // 0 1 2 3 4 int arr[] = { 10, 20, 30, 40, 50 }; * // 얕은 복사 : 같은 주소값을 가진다 int arr2[] = arr; arr2[3] = 100; * System.out.println("arr[3] = " + arr[3]); // 100 * System.out.println("arr2[3] =" + arr2[3]); // 100 System.out.println("arr = " * + arr); // [I@15db9742 System.out.println("arr..
package week2; import java.util.Scanner; public class Day11_3 { public static void main(String[] args) { // 문제1) 추가 를 선택하고 값을 입력하면 10 , 20 뒤에 저장한다. // 최대 5개까지 저장 Scanner scan = new Scanner(System.in); // 0 1 2 3 4 int[] arr = { 10, 20, 50, 60, 0 }; int cnt = 4; // 실질적으로 들어간 값 : 방번호 +1 boolean run = true; while (run) { for (int i = 0; i < cnt; i++) { System.out.print(arr[i] + " "); } System.out.p..
package week2; import java.util.Vector; public class Day11_1 { public static void main(String[] args) { // 배열 컨트롤러를 구현 : vector : 가변배열 컨트롤러 int arr[] = { 10, 20, 30, 40, 50 }; // int 하는 애는 자료형 값을 저장을 하는데 정수만 저장 for (int i = 0; i vector 클래스를 사용해서 배열 크기를 조절한다 --> 구현 // int 타입으로 만들면 정수만 들어갈 수 있다 // 처음에 배열의 크기를 지정하면 그 배열의 길이는 고정 --..