import java.util.*;
//算閏年,U805_IfIfElse.java
public class U805_IfIfElse
{
public static void main(String[] args)
{
int replay = 0;
do {
int year,rem4,rem100,rem400;
Scanner scanner = new Scanner(System.in);
System.out.print("請輸入年份: ");
year = scanner.nextInt();
System.out.println();
rem4 = year % 4;
rem100 = year % 100;
rem400 = year % 400;
/* 巢狀if */
if ( rem4 == 0 & rem100== 0 & rem400==0)
{
System.out.println(year+"是閏年");
}
else if (rem4 == 0 & rem100 != 0)
{
System.out.println(year+"是閏年");
}
else
{
System.out.println(year+"是平年");
}
System.out.print("繼續(1:繼續 0:結束)?");
replay = scanner.nextInt();
} while(replay == 1);
}
}
沒有留言:
張貼留言