"When to take medicine Problem" in Codechef Beginner. Tried all custom inputs, got it right but still wrong output after submitting

class Codechef
{
	public static void main (String[] args) throws java**strong text**.lang.Exception
	{
	    try {
	        Scanner scan = new Scanner(System.in);
    		int t = scan.nextInt();
    		scan.nextLine();
    		for(int k = 0; k < t; k++) {
    		    String[] str = scan.nextLine().split(":");
    		    Boolean leap = false;
    		    int year = Integer.parseInt(str[0]);
    		    if(year % 4 == 0) {
    		        if(year % 100 == 0) {
    		            if(year % 400 == 0) {
    		                leap = true;
    		            }
    		        } else {
    		            leap = true;
    		        }
    		    }
    		    int month = Integer.parseInt(str[1]);
    		    HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
    		    for(int i = 1; i <= 12; i++) {
    		        if(leap == true && i == 2) {
    		            map.put(i, 29);
    		        } else if(leap == false && i == 2) {
    		            map.put(i, 28);
    		        } else {
    		            if(i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) {
    		                map.put(i, 31);
    		            } else {
    		                map.put(i, 30);
    		            }
    		        }
    		    }
    		    int limit = map.get(month);
    		    System.out.println(leap);
    		    int start = Integer.parseInt(str[2]);
    		    int count = 0;
    		    for(int j = start; j <= limit; j++) {
    		        if(start % 2 == 0) {
    		            if(j % 2 != 0) {
    		                continue;
    		            } else {
    		                count++;
    		            }
    		        } else {
    		            if(j % 2 == 0) {
    		                continue;
    		            } else {
    		                count++;
    		            }
    		        }
    		    } 
    		    System.out.println(count);
    		}
	    } catch(Exception e){
	        
	    }
	}
}

I am getting wrong answer. Please help !!

Firstly, you did not comment your debugging statement:

Secondly, try this test case:
1
2019:02:28


PS: Correct answer for this test case is 16

1 Like

Can you tell why the answer is 16?
Thanks in advance!!

Ok I got it.
Thanks