-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab1_2.java
30 lines (25 loc) · 1004 Bytes
/
lab1_2.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
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Scanner;
class lab1_2 {
public static void main(String[] args) {
Scanner scan2 = new Scanner(System.in);
Calendar date2 = new GregorianCalendar();
System.out.print("День: ");
int day = scan2.nextInt();
if (day < 1 ||day > 31) {
System.out.println("error");
System.exit(-1);
}
System.out.print("Месяц: ");
int month = scan2.nextInt();
if (month < 1 || month > 12 || day > date2.getActualMaximum(Calendar.DAY_OF_MONTH) ) {
System.out.println("error");
System.exit(-1);
}
if (month >= 3 & month < 6) { System.out.println("Весна"); }
else if (month >= 6 & month < 9) { System.out.println("Лето"); }
else if (month >= 9 & month < 12) { System.out.println("Осень"); }
else if (month < 3 || month == 12) { System.out.println("Зима");}
}
}