Each new term in the Fibonacci sequence is generated by adding the previous two terms

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2 , the first 10 terms will be: By considering the terms in the Fibonacci sequence whose values do not exceed N , find the sum of the even-valued terms.
MY SOLUTION .

import java.util.Scanner;

public class FIBONACCI_SUM {

public static void main(String[] args) {
	Scanner input=new Scanner(System.in);
	int T=input.nextInt();
	while(T>0) {
	int N=input.nextInt();
	int a=1,b=2,i,ans=0,sum=0,count=0;
	for(i=1;i<=N;i++) {
		if(a<=N) {
		sum=a+b;
		a=b;
		b=sum;
		if(a%2==0) {
			ans=ans+a;
			if(ans<=N) {
				count=ans;
			}
		}
		else { 
			
		}
	}
		else {
			break;
		}
	}
	System.out.println(count);
	T--;
	}

}

}

@KUNAL.SHARMA5724510,
https://ide.codingblocks.com/s/226249 fibonacci sum of even numbers where the number is less than N code. Is this what you intended to do?

@KUNAL.SHARMA5724510,
https://ide.codingblocks.com/s/226333 correct code. Start the fibonacci from 0 ( keep a=0 and b =1).

Also, we only need the sum of even prime fibonacci numbers when the number is less than or equal to N.

And finally, use long instead of int.