View Code of Problem 81

import java.util.Scanner;
public class Main {
	public static void main(String[] args) {	
		Scanner scan = new Scanner(System.in);
		int[] days = {31,28,31,30,31,30,31,31,30,31,30,31};
		int year = scan.nextInt();
		int month = scan.nextInt()-2;
		int day = scan.nextInt();
		if(year%400==0 || (year%4==0 && year%100!=0)) {
			days[1] = 29;
		}
		int sum = 0;
		while(month>=0) {
			sum +=days[month--];
		}
		sum +=day;
		System.out.println(sum);
		scan.close();
		}
}

Double click to view unformatted code.


Back to problem 81