import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
int y, m;
int num[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
Scanner s = new Scanner(System.in);
System.out.println("Please Enter y(year) =");
y = s.nextInt();
System.out.println("Please Enter m(month) =");
m = s.nextInt();
if ((m == 2) && (((y % 400) == 0) || (((y % 100) != 0) && ((y % 4) == 0)))) {
System.out.printf("number of days %d/%d is 29¥n", y, m);
} else {
System.out.printf("number of days %d/%d is %d¥n", y, m, num[m]);
}
}
}
10
配列からの
読み出し
配列への
書き込み
うるう年の判定