예제)
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
public class Test14 {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(
new InputStreamReader(System.in));
int a,b,c;
System.out.print("년도 ?");
a=Integer. parseInt(br.readLine());
if(a%4==0&&a%100!=0||a%400==0) {
System.out.println(a+": 윤년");
} else
System.out.println(a+": 평년");
System.out.println("종료 !!!");
}
}
결과) 년도를 입력받아 평년인지 윤년인지 판별
년도 ?2013
2013: 평년
종료 !!!
'자바 > 문법' 카테고리의 다른 글
do~while 문법 (0) | 2013.05.09 |
---|---|
while 문법 (0) | 2013.05.09 |
if 연속문(세가지 숫자를 입력 받아 작은수부터 출력) (0) | 2013.05.09 |
if ~ else 문(숫자를 입력받아 절대값으로 출력) (0) | 2013.05.09 |
if ~ else if문(큰수 작은수 판별) (0) | 2013.05.09 |