숫자를 입력받아 합계 출력하기(break문 활용)
자바 프로그래밍/코드 2020. 2. 11. 00:25

import java.util.Scanner; public class Exam_03 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num=0; int sum=0; while(true) { System.out.println("수 입력(0 : 종료) :"); num = Integer.parseInt(sc.nextLine()); if(num==0) {break;} sum+=num; } System.out.println("입력한 값들의 합은 : " + sum); } }

break문, continue문
자바 프로그래밍/코드 2020. 2. 11. 00:09

//break문 public class Exam_02 { public static void main(String[] args) { int i =0; /* outer : while(true) { // 이 코드가 있는 부분을 outer라고 레이블(이름)을 지은 것 for(i=1;i

For문
자바 프로그래밍/코드 2020. 2. 10. 23:53

public class Exam_01 { public static void main(String[] args) { int i; for(i=1;i

Continue, break 연습(1~10까지 숫자 중, 1,3,4,6,7,8만 출력하기)
자바 프로그래밍/코드 2020. 2. 10. 23:53

public class Control { public static void main(String[] args) { int i; for(i=1;i

while문 이용하여 1~100 중에서 홀수만 출력하기
자바 프로그래밍/코드 2020. 2. 10. 23:51

public class Control { public static void main(String[] args) { int i = 49; // 초기값 지정 while(i

while문 이용하여 "hello java" 1,000번 출력하기
자바 프로그래밍/코드 2020. 2. 10. 23:50

//hello java 1,000번 출력 public class Quiz_09 { public static void main(String[] args) { int i = 0; while(i