Hello,
i want to write a program that will help an elementary school student to lean multiplication. For this, i use random object to produce two new positive one-digit integers. For this, i have coded this, but then got confused of the scope issue. Here is the code so far:
import java.util.Random;
import java.util.Scanner;
public class CarpimOgretme {
Random myRandom = new Random();
Scanner input = new Scanner(System.in);
public void determine(){
do{
int num1 = 1 + myRandom.nextInt(11);
int num2 = 1 + myRandom.nextInt();
int answer = num1 * num2;
int cevap = input.nextInt();
}while (answer != cevap);
}//end method
}//end class
Here, in the while block, it cannot reach answer and cevap, which means 'answer' in my language for your information. How can i reach ? Please help !!