Answer:
The problem here is you are comparing month names with == , in case of strings there is a difference between comparing with == and .equals. So I have changed that code please check now
Program:
import java.util.Scanner;
public class LabProgram {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
String inputMonth;
int inputDay;
System.out.print("Enter month:");
inputMonth = scnr.next();
System.out.print("Enter day of month");
inputDay = scnr.nextInt();
if((inputMonth.equalsIgnoreCase("march")&&inputDay>19)||inputMonth.equalsIgnoreCase("april")||inputMonth=="may"||(inputMonth.equalsIgnoreCase("june")&&inputDay<21))
{
System.out.println("spring");
}
else if((inputMonth.equalsIgnoreCase("june")&&inputDay>20)||inputMonth.equalsIgnoreCase("july")||inputMonth=="august"||(inputMonth.equalsIgnoreCase("september")&&inputDay<22))
{
System.out.println("summer");
}
else if((inputMonth.equalsIgnoreCase("september")&&inputDay>21)||inputMonth.equalsIgnoreCase("october")||inputMonth.equalsIgnoreCase("november")||(inputMonth.equalsIgnoreCase("December")&&inputDay<21))
{
System.out.println("autumn");
}
else if((inputMonth.equalsIgnoreCase("december")&&inputDay>20)||inputMonth.equalsIgnoreCase("january")||inputMonth.equalsIgnoreCase("february")||(inputMonth.equalsIgnoreCase("march")&&inputDay<20))
{
System.out.println("winter");
}
else
{
System.out.println("invalid");
} }
}
Output: