I have been working on the following for hours only to get unreachable code for line 44 return (sum);. Need some fresh eyes asap please.
package evenFibonaccisum; import java.io.*; import java.math.*; import java.text.*; import java.util.*; import java.util.regex.*; public class Sum { static int sumEvenFib(int start, int end) { int fn1 = start; //fn_1 int fn2 = getNextTerm(start); //fn_2 int fn = 0; //current term int sum = fn1 + fn2; //holds sum of even terms while (fn<=end) { fn=fn1+fn2; fn1=fn2; fn2=fn; if(fn>=end){ break ; } else{ if(fn%2==0){ sum=sum+fn; } } } int getNextTerm; int x = 0; { int a=0; int b=1; int fib=1; for(int i=0; i<=x; i++){ fib=a+b; a=b; b=fib; } return (fib); } return (sum); } private static int getNextTerm(int start) { // TODO Auto-generated method stub return 0; } private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) throws IOException { BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH"))); int start = scanner.nextInt(); scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])*"); int end = scanner.nextInt(); scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])*"); int res = sumEvenFib(start, end); bufferedWriter.write(String.valueOf(res)); bufferedWriter.newLine(); bufferedWriter.close(); scanner.close(); } }