So im a begineer in java and im trying to write a code to tell me how many days there are in a specific month but febuary is giving 29 no matter if the year is a leap year or not and i cant seem to find the reason I would really apreciate some help as i have been staring and revising this for at least an hour to no avail.Thanks to anyone who helps.
import java.util.Scanner; import static java.lang.System.out; import static java.lang.System.in; public class Calander { public static void main(String[] args) { Scanner sc = new Scanner(in); int year; int leapyear; int month; boolean leapyearTF = false; out.print("Enter the year: "); year = sc.nextInt(); out.print("Enter the month: "); month = sc.nextInt(); leapyear = year % 4; if(leapyear == 0){ leapyearTF = true; }else leapyearTF = false; leapyearTF = false; switch(month){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: out.println("There are 31 days in this month"); break; case 4: case 6: case 9: case 11: out.println("There are 30 days in this month"); case 2: if(leapyearTF = true){ out.print("There are 29 days in this month"); }else out.print("There are 28 days in this month"); break; } } }