-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathLeapYear.java
42 lines (31 loc) · 1.14 KB
/
LeapYear.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
====================================================
Aceleração Internacional Advanced Java Path
====================================================
1/3 - Leap Year?
====================================================
Challenge
Make a program that asks for a number corresponding to a certain year and then informs if this year is a leap year or not
Input
The input consists of an integer value referring to the requested year.
Output
The output should return whether the year will be a leap year or not, as shown in the example below.
Example
| Input | Output |
|-------|-----------------|
| 1996 | “Leap year” |
| 2001 | “Not leap year” |
SOLUÇÃO ABAIXO: */
import java.util.Scanner;
public class LeapYear {
public static void main(String[] args){
Scanner reader = new Scanner(System.in);
int year;
year = reader.nextInt();
String leapYear = ((year%400 == 0) || (year%4==0 && year%100!=0))
? "Leap year"
: "Not leap year";
System.out.println(leapYear);
reader.close();
}
}