예제) 콘솔로부터 검색방법(글제목 or 작성자)과 검색어를 입력 받고 , 검색내용을 출력한다.
+ 검색 방법을 잘못 입력했을 때 다시 입려하라는 메세지를 출력
+ 전체 검색(글제목 또는 작성자)을 추가한다.
여기서 반복문 for 대신에 while문이 사용되었다.
while(비교조건) { // true값일때 실행 내용
실행할 내용
실행할 내용
.
.
}
계속 true값이면 무한 반복된다.
멈추기위해서는 조건을 fasle로 맞추거나 break;를 사용하여 멈춰준다.
논리 비교 : OR( | | ) AND ( &&)
NOT ( ! ) => true이면 => fasle
false => true로 바뀜
(11968, "2020 07 08 클래스연습데이터7 (student, takes)", "김광식", 25));
(11967, "2020 07 08 클래스연습데이터5 (학과/학생)", "김정현", 62));
(11965, "2020 07 07 클래스 연습 데이터 4 (부서/사원)", "김현정", 60));
(11966, "2020 07 07 클래스 연습 데이터 4 ", "김성주", 34));
(11964, "2020 07 07 클래스 연습 데이터 3 (도서) ", "이성주", 65));
(11963, "2020 07 06 클래스 연습 데이터 2 (학생) ", "김현정", 44));
(11962, "2020 07 06 클래스 연습 데이터 (교수) ", "백태성", 48));
(11961, "2020 07 03 3가지 문제를 메서드 처리 ", "김광식", 58));
(11960, "2020 07 03 split() 와 클래스 연습 데이터", "김정현", 54));
(11959, "2020 07 02 마지막 3가지 문제 ", "박광수", 92));
(11958, "2020 07 02 split test ", "김현정", 53));
(11957, "2020 07 02 제어문 연습데이터 ", "김정현", 64));
(11956, "코드를 엉망으로 작성하는 법 ", "박광수", 43));
(11955, "유지 보수 어렵게 코딩하는 방법 ", "김광식", 59));
(11954, "2020 07 01 Java Platform Standard Edition 8 Documentation ","Amor vincit omnia", 29));
(11641, "2019 01 30 변수, 배열, 객체, 클래스 (기초 문법 간단 요약) ", "박광수", 91));
(11640, "2019 01 30 변수, 배열, 객체, 클래스 (기초 문법 간단 요약) ", "김성주", 95));
(11639, "2019 01 30 기본 지식 정리 ", "김성주", 70));
예제) 콘솔로부터 입력받은 값(ex:"종합지")을 이용하여 해당 신문들의 정보와 갯수를 출력
단, 출력은 PrintClass에서만해야하며 신문들의 정보 출력시 image는 확장자를 포함하고 url은 전체가 다 나와야한다. // NewsClass에서 변수를 선언 할때는 image확장자를 제거하고 url은 뒤 숫자 부분만 저장
for (데이터를 저장할 변수('A'라고 가정) : 다중값(배열/ArrayList)<='B'라고 가정){
실행내용
}
B의 데이터가 없어질때까지 꺼내서 A라는 변수에 저장 한다는 뜻!!
resultList에 담아둔 객체들을 news라는 새로운 변수에 저장해서 결과값을 출력한다.
("경향신문", "nsd16500796.gif", "newsstand.naver.com/032", "종합지"));
("국민일보", "nsd113224489.gif", "newsstand.naver.com/005", "종합지"));
("동아일보", "nsd162737318.gif", "newsstand.naver.com/020", "종합지"));
("서울신문", "nsd165611664.gif", "newsstand.naver.com/081", "종합지"));
("석간내일신문", "nsd162522149.gif", "newsstand.naver.com/086", "종합지"));
("석간문화일보", "nsd11502601.gif", "newsstand.naver.com/021", "종합지"));
("세계일보", "nsd104440320.gif", "newsstand.naver.com/022", "종합지"));
("조선일보", "nsd14948476.gif", "newsstand.naver.com/023", "종합지"));
("중앙일보", "nsd111948440.gif", "newsstand.naver.com/025", "종합지"));
("한계레", "nsd185116392.gif", "newsstand.naver.com/028", "종합지"));
("한국일보", "nsd141114194.gif", "newsstand.naver.com/038", "종합지"));
("NEWis", "nsd165223437.gif", "newsstand.naver.com/003", "방송통신"));
("jijicom", "nsd112912516.gif", "newsstand.naver.com/376", "방송통신"));
("한국경제", "nsd10118864.gif", "newsstand.naver.com/215", "방송통신"));
("KBS", "nsd164033826.gif", "newsstand.naver.com/056", "방송통신"));
("MBC", "nsd1453778.gif", "newsstand.naver.com/214", "방송통신"));
("MBN", "nsd163758547.gif", "newsstand.naver.com/057", "방송통신"));
("SBS", "nsd183257911.gif", "newsstand.naver.com/055", "방송통신"));
("YTN", "nsd17425192.gif", "newsstand.naver.com/052", "방송통신"));
("매일경제", "nsd113526120.gif", "newsstand.naver.com/009", "경제지"));
("머니투데이", "nsd113754824.gif", "newsstand.naver.com/008", "경제지"));
("서울경제", "nsd15338959.gif", "newsstand.naver.com/011", "경제지"));
("아시아경제", "nsd165753754.gif", "newsstand.naver.com/277", "경제지"));
("이데일리", "nsd111247840.gif", "newsstand.naver.com/018", "경제지"));
("ChosunBiz", "nsd19334215.gif", "newsstand.naver.com/366", "경제지"));
("파이낸셜뉴스", "nsd141641302.gif", "newsstand.naver.com/014", "경제지"));
("한국경제", "nsd162034351.gif", "newsstand.naver.com/015", "경제지"));
("해럴드경제", "nsd182749494.gif", "newsstand.naver.com/016", "경제지"));
("노컷뉴스", "nsd101424267.gif", "newsstand.naver.com/079", "인터넷"));
("NEWDAILY", "nsd102245777.gif", "newsstand.naver.com/327", "인터넷"));
("데일리안", "nsd184410246.gif", "newsstand.naver.com/368", "인터넷"));
("미디어오늘", "nsd124110953.gif", "newsstand.naver.com/006", "인터넷"));
("OhmyNews", "nsd102039590.gif", "newsstand.naver.com/047", "인터넷"));
("PRESSian", "nsd184630885.gif", "newsstand.naver.com/002", "인터넷"));
("디지털타임스", "nsd144911195.gif", "newsstand.naver.com/029", "IT영자지"));
("블로터닷넷", "nsd16353971.gif", "newsstand.naver.com/293", "IT영자지"));
("아이뉴스24", "nsd113110902.gif", "newsstand.naver.com/031", "IT영자지"));
("월스트리트저널", "nsd16110689.gif", "newsstand.naver.com/372", "IT영자지"));
("전자신문", "nsd11405830.gif", "newsstand.naver.com/030", "IT영자지"));
("JOONGANG DAILY", "nsd113635939.gif", "newsstand.naver.com/330", "IT영자지"));
("Net Korea", "nsd18341092.gif", "newsstand.naver.com/092", "IT영자지"));
("THE KOREA TIMES", "nsd92244365.gif", "newsstand.naver.com/040", "IT영자지"));
("The Korea Herald", "nsd183039979.gif", "newsstand.naver.com/044", "IT영자지"));
("KBS WORLD", "nsd14465916.gif", "newsstand.naver.com/326", "IT영자지"));
("마이데일리", "nsd113852954.gif", "newsstand.naver.com/117", "스포츠연예"));
("스포츠동아", "nsd16247594.gif", "newsstand.naver.com/314", "스포츠연예"));
("스포츠서울", "nsd184854466.gif", "newsstand.naver.com/073", "스포츠연예"));
("스포츠조선", "nsd184717404.gif", "newsstand.naver.com/076", "스포츠연예"));
("sportalkorea", "nsd16579942.gif", "newsstand.naver.com/139", "스포츠연예"));
("일간스포츠", "nsd113052387.gif", "newsstand.naver.com/241", "스포츠연예"));
("OSEN", "nsd102852391.gif", "newsstand.naver.com/109", "스포츠연예"));
("GameMeca", "nsd183724.gif", "newsstand.naver.com/356", "매거진전문지"));
("과학동아", "nsd165049622.gif", "newsstand.naver.com/363", "매거진전문지"));
("jungle", "nsd165310840.gif", "newsstand.naver.com/345", "매거진전문지"));
("Software", "nsd113744707.gif", "newsstand.naver.com/357", "매거진전문지"));
("법률신문", "nsd165524289.gif", "newsstand.naver.com/122", "매거진전문지"));
("ScienceTimes", "nsd113446808.gif", "newsstand.naver.com/355", "매거진전문지"));
("소년한국일보", "nsd102746161.gif", "newsstand.naver.com/329", "매거진전문지"));
("STYLECOM", "nsd18366175.gif", "newsstand.naver.com/367", "매거진전문지"));
("시사IN Live", "nsd182936757.gif", "newsstand.naver.com/308", "매거진전문지"));
("씨네21", "nsd185025147.gif", "newsstand.naver.com/140", "매거진전문지"));
("Ablenews", "nsd184148949.gif", "newsstand.naver.com/328", "매거진전문지"));
("ELLE", "nsd16411268.gif", "newsstand.naver.com/354", "매거진전문지"));
("여성신문", "nsd164815489.gif", "newsstand.naver.com/310", "매거진전문지"));
("CARLIFE", "nsd135857948.gif", "newsstand.naver.com/362", "매거진전문지"));
("조세신문", "nsd101830214.gif", "newsstand.naver.com/123", "매거진전문지"));
("채널예스", "nsd14034411.gif", "newsstand.naver.com/361", "매거진전문지"));
("코메디닷컴", "nsd14156354.gif", "newsstand.naver.com/296", "매거진전문지"));
("한경BUSINESS", "nsd114627265.gif", "newsstand.naver.com/050", "매거진전문지"));
("한국대학신문", "nsd18493839.gif", "newsstand.naver.com/384", "매거진전문지"));
("헬스조선", "nsd17329660.gif", "newsstand.naver.com/346", "매거진전문지"));
("EBS", "nsd145514832.gif", "newsstand.naver.com/344", "매거진전문지"));
("PC사랑", "nsd15129878.gif", "newsstand.naver.com/364", "매거진전문지"));
("강원도민일보", "nsd16493440.gif", "newsstand.naver.com/335", "지역지"));
("강원일보", "nsd18354817.gif", "newsstand.naver.com/087", "지역지"));
("경기일보", "nsd142922938.gif", "newsstand.naver.com/339", "지역지"));
("경남일보", "nsd11120405.gif", "newsstand.naver.com/333", "지역지"));
("경북일보", "nsd103125356.gif", "newsstand.naver.com/337", "지역지"));
("경인일보", "nsd75053515.gif", "newsstand.naver.com/338", "지역지"));
("광주일보", "nsd113635473.gif", "newsstand.naver.com/083", "지역지"));
("국제신문", "nsd11332053.gif", "newsstand.naver.com/332", "지역지"));
("대전일보", "nsd11342450.gif", "newsstand.naver.com/089", "지역지"));
("매일신문", "nsd184317799.gif", "newsstand.naver.com/088", "지역지"));
("부산일보", "nsd8215253.gif", "newsstand.naver.com/082", "지역지"));
("영남일보", "nsd165845221.gif", "newsstand.naver.com/385", "지역지"));
("울산메일", "nsd14643703.gif", "newsstand.naver.com/386", "지역지"));
("인천일보", "nsd14814726.gif", "newsstand.naver.com/387", "지역지"));
("전남일보", "nsd14941869.gif", "newsstand.naver.com/388", "지역지"));
("전북일보", "nsd183759971.gif", "newsstand.naver.com/336", "지역지"));
("제주도민일보", "nsd19513821.gif", "newsstand.naver.com/389", "지역지"));
("제주의소리", "nsd115524760.gif", "newsstand.naver.com/334", "지역지"));
("중도일보", "nsd17122649.gif", "newsstand.naver.com/390", "지역지"));
("충청일보", "nsd162144955.gif", "newsstand.naver.com/391", "지역지"));
("충청투데이", "nsd14118621.gif", "newsstand.naver.com/331", "지역지"));
("OBS", "nsd101932455.gif", "newsstand.naver.com/340", "지역지"));
이 문제는 출력을 PrintClass에 하는거 말고는 위 예제랑 비슷하다.
'Learn > KH정보교육원' 카테고리의 다른 글
[KH정보교육원 당산] 연습 문제1 (프로그래밍 언어 활용) (0) | 2021.03.21 |
---|---|
[KH정보교육원 당산] 8일차 (File클래스, Buffered 클래스) (0) | 2021.03.19 |
[KH정보교육원 당산] 6일차 (분할 시키기 연습, ArrayList 사용) (0) | 2021.03.17 |
[KH정보교육원 당산] 5일차 (메인,메소드,데이터 각 역할을 분할 시키는 연습) (0) | 2021.03.16 |
[KH정보교육원 당산] 4일차(String 메소드, 비교연산) (0) | 2021.03.15 |