import java.util.Scanner;
public class Test {
public static void main(String[] args) {
System.out.print("Please input the month to check:");
int month = new Scanner(System.in).nextInt();
if (month <= 0 || month > 12) {
System.out.println("Error! month must be between 1 and 12!");
} else if (month <= 3) {
System.out.println("Month " + month + " is in Spring!");
} else if (month <= 6) {
System.out.println("Month " + month + " is in Summer!");
} else if (month <= 9) {
System.out.println("Month " + month + " is in Autumn!");
} else {
System.out.println("Month " + month + " is in Winter!");
}
--------------------
Please input the month to check:7
Month 7 is in Autumn!
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
System.out.print("Please input the month to check:");
int month = new Scanner(System.in).nextInt();
if (month <= 0 || month > 12) {
System.out.println("Error! month must be between 1 and 12!");
} else if (month <= 3) {
System.out.println("Month " + month + " is in Spring!");
} else if (month <= 6) {
System.out.println("Month " + month + " is in Summer!");
} else if (month <= 9) {
System.out.println("Month " + month + " is in Autumn!");
} else {
System.out.println("Month " + month + " is in Winter!");
}
}
}
--------------------
Please input the month to check:7
Month 7 is in Autumn!