I have done up this cope to ask elementary students to solve the multiplication problems. The only problem I have is when the student gets the wrong answer, I don't know how to get the same problem back for them to answer the question again. Can someone point me to the right direction.

// Displaying multiple strings
import javax.swing.*;                  // to use JOptionPane.showInputDialog box
import java.util.Random;             // to use Random number generator

public class Assignment4 extends JApplet
{
     int randomValue1;              // stores each random integer generated
     int randomValue2;              // stores each random integer generated
     int biggestValue = 9;          // biggest random number is 9
     int smallestValue = 0;        // smallest random number is 0
     int moreInt = 1;                // loop control variable 
     int counter = 0;                 // inital counter
     int rightAnswers = 0;         // correct answers
	
     String results = "";            // stores the results
     String input = "";              // user input
     String question = "";         // question that will be asking
     String output = "";            // will show if the student needs help or not
	
     // method for asking question
     public String questionGenertor( int num1, int num2)
     {
        return "How much is " + num1 + " times " + num2 + "?";
      }
			
          // initialize applet by obtaining values from user 	    
          public void init()
          {
             Random randomNumbers = new Random();     // random number generator
		
	 while (moreInt == 1){
		
	          for (counter = 0; counter < 10; counter ++)
	          {
                              randomValue1 = randomNumbers.nextInt (biggestValue - smallestValue ) + 1;   
                              // random numbers between (1-10)
			
	              randomValue2 = randomNumbers.nextInt (biggestValue - smallestValue ) + 1;
                              // random numbers between (1-10)
				
	              question = questionGenertor (randomValue1, randomValue2);
			
			
	              // asking the user a math question		
	              results = JOptionPane.showInputDialog (question,"");
				
	              if (results.equals("" + randomValue1 * randomValue2))
		{
                                     JOptionPane.showMessageDialog( null, "Very Good");
	                     rightAnswers += 1;
		} 
	              else  
	                {
	                     JOptionPane.showMessageDialog(null, "No, Please try again.");
										                 }  // end if statement
						        
	               } // end for loop
			
                   // asking 
                   input = JOptionPane.showInputDialog( 
                               "Another group of Math problems?\n   1 - yes\n   2 - no\n" );
                    
                   moreInt = Integer.parseInt( input );
         
         
	} // end while loop
		
				
     } // end 
		
} // end main
question = questionGenertor (randomValue1, randomValue2);
	              // asking the user a math question		

boolean wrongAnswer=true;
while (wrongAnswer) {

	              results = JOptionPane.showInputDialog (question,"");
	              if (results.equals("" + randomValue1 * randomValue2))
		{
                                     JOptionPane.showMessageDialog( null, "Very Good");
	                     rightAnswers += 1;
                             wrongAnswer = false;
		} 
	              else  
	                {
	                     JOptionPane.showMessageDialog(null, "No, Please try again.");
			}  // end if statement

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.