JAVA 프로그래밍/Do it! 자바 프로그래밍 입문
loopexample/ContinueExample.java
불두화
2021. 5. 12. 19:00
이전까지 했던 책의 예제들 업로드합니다.
감사합니다.
package loopexample;
public class ContinueExample {
public static void main(String[] args) {
int total = 0;
int num;
for(num = 1; num <= 100; num++) {
if(num % 2 == 0)
continue;
total += num;
}
System.out.println("1부터 100까지의 홀수의 합은: "+total + "입니다.");
}
}