제어문(38)
-
ContinueEx01.java-continue문
1~10출력할 때 3의 배수는 출력하지 않기 소스코드 public class ContinueEx01 { public static void main(String[] args) { // 특정조건일때 continue문으로 다음 회차로 건너뛰기 // 1~10출력할 때 3의 배수는 출력하지 않기 for(int i =0; i
-
ContinueEx02-3의 배수가 아니거나 7의 배수가 아니라면 출력하고 카운트 증가시키기
3의 배수가 아니거나 7의 배수가 아니라면 출력하고 카운트 증가시키기 소스코드 public class ContinueEx02 { public static void main(String[] args) { int num=0; int count=0; while((num++)
-
ForEx03.java-for문
1부터 100까지의 누적 합 구하기 소스코드 public class ForEx03 { public static void main(String[] args) { int total = 0; for(int i=1; i
-
ForEx02.java-비교인자값 감소/증가 시키기
비교인자값 감소/2씩 증가시키기 소스코드 public class ForEx02 { public static void main(String[] args) { // 비교인자값 감소 System.out.println("비교 인자값 1씩 감소 시키기:"); for(int i=5; i>=1; i--){ System.out.print("\t"+ i); } System.out.println(); System.out.println("\t프로그램 종료!"); // 비교인자값 2씩 증가시키기 System.out.println(); System.out.println("비교 인자값 2씩 증가시키기 1:"); for(int i=0; i
-
ForEx01.java-for()문, 비교 인자값 증가
비교 인자값 증가 소스코드 public class ForEx01 { public static void main(String[] args) { for( int i=1; i
-
SwitchEx05-no break/switch+break
switch~case문과 switch~case~default 레이블 유무에 따른 출력결과 확인 소스코드 public class SwitchEx05 { public static void main(String[] args) { int n=3; // int n=7; // int n=10; switch(n) { case 1: System.out.println("First"); case 2: System.out.println("Second"); case 3: System.out.println("Thrid"); case 4: System.out.println("Fourth"); case 5: System.out.println("Fifth"); case 6: System.out.println("Sixth"); cas..