for (count=1; count<=10; count++)    
            number1= randomNumber.nextInt(10)+1;
            number2= randomNumber.nextInt(10)+1;
            Help correct= new Help(number1, number2); 


                                    case 2:
                    if (number1 > number2)

                        System.out.print("What is the answer to this problem? " +
                                      number1 + "-" + number2 + ":");
                        ans= keyboard.nextInt();//stops at 2 problems!!!!!!

                    a= correct.getSub();

                    if(ans == a)

                        System.out.println("The answer is CORRECT!!!!!");
                        rigth +=1;
                        System.out.println("The answer is INCORRECT!!!");
                       System.out.println("The correct answer is: " +a);

Edited by Nick Evan: Fixed formatting

7 Years
Discussion Span
Last Post by jon.kiparsky

Obviously this is meant to generate arithmetic problems, so the random is fine. This gives you randomly generated subtraction problems.

Why it stops is not obvious from this code. Potential problem spots would include the switch value - what is "choice" and does it change in the loop? If it does, what are the other cases of the switch? If if doesn't change, why check against it repeatedly? The continuation of the if statement bothers me as well - what happens if number2>number1 or number2==number1? Also, just for giggles, let's just make sure you have your break statements in each case of the switch. Always worth checking for that.

Whether it's one of these or something else, I can't say without seeing more code. Any further code ought to be posted in code tags. Select your code and click on the (code) button above the text entry box.

Edited by mike_2000_17: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.