I'm trying to evaluate an equation randomly generated by the system where the two integers are stored in an array and the operator is in a separate string array. I want to compare the answer with the user's answer. here is my code:
Integer[] array;
String[] operators = {"+", "-", "*", "/"};
String question;
int operator = 0;
public void generateSum(){
for (int x = 0; x < 2; x++) {
Random randomNumber = new Random(); //creating random object
int number = randomNumber.nextInt(100) + 1;
Random randomOperator = new Random();
operator = randomOperator.nextInt(3);
array[x] = (number);
}
question = array[0].toString() + operators[operator] + array[1].toString() + "=";
TextView txt = findViewById(R.id.txtQuestion);
txt.setText(question);
}