Published: 09 Mar 2018 › Updated: 09 Mar 2018

두번째 개발일지
안녕하세요 #a991102 입니다
오늘 두번째 개발일지를 올려보도록 하겠습니다.
부족한글이지만 그래도 읽어주시면 감사하겠습니다.
오늘도 여러개를 해봤는데요 그중에서 두개정도만 정리해서 올려보겠습니다.
package 삼월구일;
import java.util.Scanner;
public class FlowEx17 {
public static void main(String args[]) {
int num = 0;
System.out.println("*을 출력할 라인의 수를 입력하세요");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.nextLine();
num = Integer.parseInt(tmp);
for(int i = 0; i<num; i++){ //i 는 0부터 num(입력된숫자) 보다 클때까지 반복하면 서 1씩증가한다
for(int j=0; j<=i; j++){ // j 는 0부터 i까지 1씩 증가하면서 반복한다
System.out.println("*");
}
System.out.println("");
}
}
}
별을 찍는 예제 입니다. 생각보다 간단하죠 ?
ㅎㅎ 그럼 다음 예제 올리겠습니다.
package 삼월구일;
import java.util.Scanner;
public class FlowEx11 {
public static void main(String args[]) {
char gender ;
String regNo = "";
System.out.println("당신의 주민번호를 입력하세요 (000000-0000000)");
Scanner scan = new Scanner(System.in); // scan 이라는 스캐너를 생성 한다 그리고 (System.in) 는 입력받는 방식이다 위예제는 직접 콘솔창에 입력받는다고 하였다.
regNo = scan.nextLine(); //Scan 한문장을 입력받는다 입력받은 문장을 regNo 에 저장한다.
gender = regNo.charAt(7); // regNo 문자열중 7이후에 문자를 가져옵니다.
switch (gender) { //gender 값을 확인하고 1이거나 3이면 밑에 또다른 스위치문으로가서 1 or 3 이면 조건문을 실행합니다.
// 성별을 구분하고 2000년생 이전 출생자인지 이후출생자인지 검사하는 구간 입니다.
case 1:
case 3:
switch (gender) {
case '1':
System.out.println("당신은 2000년생 이전 남자 출생자입니다");
break;
case '3' :
System.out.println("당신은 2000년생 이후 남자 출생자 입니다.");
break;
}
case '2':
case '4':
switch(gender){
case '2' :
System.out.println("당신은 2000년생 이전 여자 출생자 입니다.");
break;
case '4' :
System.out.println("당신은 2000년생 이후 여자 출생자 입니다.");
break;
}
break;
default :
System.out.println("유효하지 않는 주민등록 번호 입니다. 출생신고를 다시하고 와주세요");
}
}
}
// switch 문을 이용해서 성별/2000년생 이후 , 이전 출생자 검출하기
이상으로 두번째 개발일지를 다마쳤습니다 ㅎㅎ
내일다시 봐용 ~
Leave 두번째 개발일지 to:
Read more #kr posts
Best Posts From 플리드
We have not curated any of a991102's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.