- 반복문은 총합을 구할 때 사용한다.
- 1부터 10까지의 "총합"은 55이다. > total += i(total = total + i)
/*
total = 1;
total = total + 1; //2
total = total + 2; //2 + 2 > 4
...
total = totla + 10 //55
*/
- 영문 대문자를 출력하세요.
- 영문 대문자는 65 ~ 90 숫자로 이루어져 있다. 숫자 사이의 간격은 1이다.
- 영문 소문자를 출력하세요.
- 영문 소문자는 97 ~ 122 숫자로 이루어져 있다. 숫자 사이의 간격은 1이다.
package com.dream.controls;
public class ForEx04 {
public static void main(String[] args) {
int total = 0;
for(int i=1; i<=10; i++) {
total += i; //total = total + i;
}
System.out.println(total);
for(int i=65; i<=90; i++) {
System.out.print("\t"+(char)i);
}
System.out.println("\n");
for(int i=97; i<=122; i++) {
System.out.print("\t"+(char)i);
}
}
}