public class BreakExample {
public static void main(String[] args) {
// TODO Auto-generated method stub
while(true) {
int num = (int)(Math.random() * 6) + 1;
System.out.println(num);
if(num == 6) {
break;
}
}
System.out.println("프로그램 종료");
}
}
public class BreakOutterExample {
public static void main(String[] args) {
// TODO Auto-generated method stub
Outter: for(char upper = 'A'; upper <= 'Z'; upper++) {
for(char lower = 'a'; lower <= 'z'; lower++) {
System.out.println(upper + "-" + lower);
if(lower == 'g') {
break Outter;
}
}
}
System.out.println("프로그램 실행 종료");
}
}
public class ContinueExample {
public static void main(String[] args) {
// TODO Auto-generated method stub
for(int i = 1; i <= 10; i++) {
if(i % 2 != 0) {
continue;
}
System.out.println(i);
}
}
}
public class ForFloatCounterExample {
public static void main(String[] args) {
// TODO Auto-generated method stub
for(float x = 0.1f; x <= 1.0f; x += 0.1f) {
System.out.println(x);
}
}
}
public class ForMultiplicationTableExample {
public static void main(String[] args) {
// TODO Auto-generated method stub
for(int m = 2; m <= 9; m++) {
System.out.println("*** " + m + "단 ***");
for(int n = 1; n <= 9; n++) {
System.out.println(m + " x " + n + " = " + m * n);
}
}
}
}
public class ForPrintFrom1To10Example {
public static void main(String[] args) {
// TODO Auto-generated method stub
for(int i = 1; i <= 10; i++) {
System.out.println(i);
}
}
}
public class ForSumFrom1To100Example {
public static void main(String[] args) {
// TODO Auto-generated method stub
int sum = 0;
for(int i = 1; i <= 100; i++) {
sum += i;
}
System.out.println("1 ~ 100 합 : " + sum);
}
}
public class WhilePrintFromt1To10Example {
public static void main(String[] args) {
// TODO Auto-generated method stub
int i = 1;
while(i <= 10) {
System.out.println(i);
i++;
}
}
}
public class WhileSumFrom1To100Example {
public static void main(String[] args) {
// TODO Auto-generated method stub
int sum = 0;
int i = 1;
while(i <= 100) {
sum += i;
i++;
}
System.out.println("1 ~ " + (i - 1) + " 합 : " + sum);
}
}