# Loop
package com.work.view;
public class LoopTest {
public static void main(String[] args) {
int total = 0;
System.out.println("\n1. for 구문");
for (int i = 1; i <= 5; i++) {
System.out.println(i);
total += i;
}
System.out.println("total = " + total);
total = 0;
System.out.println("\n2. while 구문");
int i = 1;
while(i <= 5) {
System.out.println(i);
total += i;
i++;
}
System.out.println("total = " + total);
total = 0;
i = 1;
System.out.println("\n3. do~while 구문");
do {
System.out.println(i);
total += i;
i++;
} while(i <= 5);
System.out.println("total = " + total);
}
public static void main2(String[] args) {
for(char i = 'A'; i <= 'z'; i++) {
System.out.println(i + " : " + (int)i);
}
}
public static void main1(String[] args) {
int total = 0;
for (int i = 1; i <= 10; i++) {
if (i % 2 == 0) {
System.out.println(i);
total += i;
}
}
System.out.println("total : " + total);
}
}