목록JAVA (28)
백지부터 시작하는 이세계 코딩 생활

public class callByFunction2 { public callByFunction2() { // 컨트롤 + 스페이스를 눌러서 만들기를 활성화 후 생성할 수 있다. // do-whilefunction test. doWhileTset2(); }// end callByFunction2 private void doWhileTset2() { char ch = 'A'; do { System.out.println(ch); ch = (char) (ch + 1); // 형변환 해줌. // 형변환 없이 하는 방법: ch++; } while (ch

enum : 배열 처럼 사용 할 수 있는 매서드? - 이런 함수도 있구나 ! public class Ch03Ex09_enum_example { enum Week { Mon, Thu, Wed,Thr, Fri, Sat, Sun} public static void main(String[] args) { // TODOAuto-generated method stub int [] n = {1,2,3,4,5}; String names[] = {"apl,pear, bana,cher,stro,gra"}; int sum = 0; // 아래 for-each 에서는 k는 n[0],n[1] ... n[4] 로 반복함. for (int k : n) { System.out.println(k+" "); //반복값 프린트. sum +..

값을 입력받고 결과를 출력한다. 값을 출력 할 때는 등급, 평균, 랭크까지 함께 출력되게 한다. import java.util.Scanner; import static java.lang.System.out; public class s0504_성적출력_sol { static final int MAX = 100; static int top = 0; // 현재 입력 위치 index static String[] name = new String[MAX]; static int[] kor = new int[MAX]; static int[] eng = new int[MAX]; static int[] mat = new int[MAX]; static int[] total = new int[MAX]; static doubl..
package s0429; import java.util.Scanner; public class Ch05_HW { static int days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; static int year = 0; static int month = 0; static int day = 0; static int integDay = 0; static int afterDay = 0; static int tempDay = 0; static int diffDay = 0; static int dayTotal = 0; static int newDiffDay = 0; static int newMonth = 0; static int newDay = 0; s..
package project0427; import java.util.Random; import java.util.Scanner; public class HW0428 { public static void main(String[] args) { // TODO Auto-generated method stub // Math.random() // Random 클래스를 이용 (난수발생기), 범위지정필요. /* * 정답이면 빙고 메세지 프린트 * 오답이면 큰수인지 작은수인지 알려주기 * 예외처리 --> 재입력 시행 * --- 한 세트당 중간 메세지 프린트 --- * 기회는 6번으로 셋팅 * 마지막 프린트, y or n 만 입력받기(문자만 인식되기) */ //선택지 관련 변수 //int YES, yes, Yes, yE..

// TODO Auto-generated method stub // 3행3열로 구구단 프린트 // 시작단과 종료단 합치기 // 2단 3단 4단 // 5단 6단 7단 // 8단 9단 - // ex) 입력값으로부터 9단까지 3행3열 형태를 유지하며 프린트하기 // 입력값 : 4, // 프린트는 다음과 같이 // 4단 5단 6단 // 7단 8단 9단
case 1 : // * // ** // *** // **** // ***** // **** // *** // ** // * case 2 : // ***** // **** // *** // ** // * // ** // *** // **** // ***** case 3: // ^^^^* // ^^^** // ^^*** // ^**** // ***** // ^**** // ^^*** // ^^^** // ^^^^* case 4: // ***** // **** // *** // ** // * // ** // *** // **** // ***** case 5: // ^^^^* // ^^^*** // ^^***** // ^******* // ********* case 6: // ********* // **** ..

public static void main(String[] args) { // TODO Auto-generated method stub int[][] arr = new int[3][3]; int num = 1; int i = 0; int j = 0; // 2차원 배열은 다중 for문으로 접근한다. arr[0][0] = 10; arr[1][1] = 22; arr[2][2] = 33; for (int r = 0; r < 3; r++) { for (int c = 0; c < 3; c++) { System.out.print(arr[r][c] + "\t"); } System.out.println(); } }// end main //결과는 다음과 같다 행렬의 형태로 프린트 되며 각 주소지에 입력해준 값들만 프린트됨..