Terminate Program On -1 -1 input not working
<p>I'm doing some ICPC programming problems for fun this one is Collatz. I've gotten an output that fits the expected output correctly. But I've been having problems getting the program to end when it comes to the -1 -1 input as desired.</p>

<p>Sample Input</p>

<pre><code>3 100
34 100
75 250
27 2147483647
101 304
101 303
-1 -1
</code></pre>

<p>Expected Output</p>

<pre><code>Case 1: A = 3, limit = 100, number of terms = 8 

Case 2: A = 34, limit = 100, number of terms = 14 

Case 3: A = 75, limit = 250, number of terms = 3  

Case 4: A = 27, limit = 2147483647, number of terms = 112

Case 5: A = 101, limit = 304, number of terms = 26 

Case 6: A = 101, limit = 303, number of terms = 1
</code></pre>

<p>Java Code</p>

<pre><code>import java.util.Scanner;
import java.lang.Integer;

public class Collatz {
    private static int caseNumber = 0;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNext()) {
            caseNumber++;
            int a = in.nextInt();
            Integer limit = in.nextInt();
            if(a == -1 &amp;&amp; limit == -1)
                break;
            int numberOfTerms = 0;
            for(Integer value = a; value != 1; numberOfTerms++){
                if(value%2 == 0){
                    value /= 2;
                }else{
                    value = 3 * value + 1;
                }
                if(limit &lt; value)
                    break;
            }
            numberOfTerms +=1;
            System.out.println("Case " + caseNumber + ": A = " + a + ", limit = "
                    + limit + ", number of terms = " + numberOfTerms);
            System.out.println();

        }
    }
}
</code></pre>
