-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonthsAndYear.java
More file actions
74 lines (50 loc) · 1.23 KB
/
MonthsAndYear.java
File metadata and controls
74 lines (50 loc) · 1.23 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import java.util.Scanner;
public class MonthsAndYear{
public static void main(String[] args){
Scanner bird = new Scanner(System.in);
System.out.print("Enter month: ");
int month = bird.nextInt();
System.out.print("Enter year: ");
int year = bird.nextInt();
int leapyear = year%4;
if (month == 1){
System.out.printf("%d January has 31 days", year);
}
if (leapyear == 0 && month == 2){
System.out.printf("%d is a leap yarFebruary has 29 days", year);
}
if (leapyear != 0 && month == 2){
System.out.printf("%d February has 28 days", year);
}
if (month == 3){
System.out.printf("%d March has 31 days", year);
}
if (month == 4){
System.out.printf("%d April has 30 days", year);
}
if (month == 5){
System.out.printf("%d May has 31 days", year);
}
if (month == 6){
System.out.printf("%d June has 30 days", year);
}
if (month == 7){
System.out.printf("%d July has 31 days", year);
}
if (month == 8){
System.out.printf("%d August has 31 days", year);
}
if (month == 9){
System.out.printf("%d September has 30 days", year);
}
if (month == 10){
System.out.printf("%d October has 31 days", year);
}
if (month == 11){
System.out.printf("%d November has 30 days", year);
}
if (month == 12){
System.out.printf("%d December has 31 days", year);
}
}
}