First of all i´m a begginer and i know this code is very basic, but i really want to know the problem and how to fix it. There ar no compile error or logical errors i think, but nothing appears on the console. Can someone help? Thanks.
import java.util.Scanner;
public class A {
public static void main(String args[]){
Scanner input = new Scanner(System.in);
System.out.print("Enter the month: ");
String month = input.nextLine();
System.out.print("Enter the year: ");
int year = input.nextInt();
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)){ // if it is a leap year
if (month == "January")
System.out.print(month + " " + year + " has " + "31 days");
else if (month == "February")
System.out.print(month + " " + year + " has " + "29 days");
else if (month == "March")
System.out.print(month + " " + year + " has " + "31 days");
else if (month == "April")
System.out.print(month + " " + year + " has " + "30 days");
else if (month == "May")
System.out.print(month + " " + year + " has " + "31 days");
else if (month == "June")
System.out.print(month + " " + year + " has " + "30 days");
else if (month == "July")
System.out.print(month + " " + year + " has " + "31 days");
else if (month == "August")
System.out.print(month + " " + year + " has " + "31 days");
else if (month == "September")
System.out.print(month + " " + year + " has " + "30 days");
else if (month == "October")
System.out.print(month + " " + year + " has " + "31 days");
else if (month == "November")
System.out.print(month + " " + year + " has " + "30 days");
else if (month == "December")
System.out.print(month + " " + year + " has " + "31 days");
}
else { // If it´s not a leap year
if (month == "January")
System.out.print(month + " " + year + " has " + "31 days");
else if (month == "February")
System.out.print(month + " " + year + " has " + "28 days");
else if (month == "March")
System.out.print(month + " " + year + " has " + "31 days");
else if (month == "April")
System.out.print(month + " " + year + " has " + "30 days");
else if (month == "May")
System.out.print(month + " " + year + " has " + "31 days");
else if (month == "June")
System.out.print(month + " " + year + " has " + "30 days");
else if (month == "July")
System.out.print(month + " " + year + " has " + "31 days");
else if (month == "August")
System.out.print(month + " " + year + " has " + "31 days");
else if (month == "September")
System.out.print(month + " " + year + " has " + "30 days");
else if (month == "October")
System.out.print(month + " " + year + " has " + "31 days");
else if (month == "November")
System.out.print(month + " " + year + " has " + "30 days");
else if (month == "December")
System.out.print(month + " " + year + " has " + "31 days");
}
}
}