Skip to content

Instantly share code, notes, and snippets.

@mamiwinsfall93
Created January 17, 2020 14:10
Show Gist options
  • Save mamiwinsfall93/08ffd8c3e3acf47b87023776cac60fd8 to your computer and use it in GitHub Desktop.
Save mamiwinsfall93/08ffd8c3e3acf47b87023776cac60fd8 to your computer and use it in GitHub Desktop.
Number of days in the year
/*
Use the keyboard to enter a year, and then determine the number of days in the year. Display the result as follows:
Number of days in the year: x
, where
x is 366 for a leap year, and
x is 365 for an ordinary year.
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
InputStreamReader sreader = new InputStreamReader (System.in);
BufferedReader br = new BufferedReader (sreader);
int year = Integer.parseInt(br.readLine());
int x =366;
int y= 365;
if (year %400==0){
System.out.println("Number of days in the year: "+x);
}else if (year %100==0){
System.out.println("Number of days in the year: "+y);
}else if (year%4==0 ){
System.out.println("Number of days in the year: "+x);
}else {
System.out.println("Number of days in the year: "+y);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment