External Exam Download Resources Web Applications Games Recycle Bin

maths Blaster



setup Form
Maths Blaster jFrame Form
import Package
import java.util.Random;

public Variables And Constructor

btnNewSum
Random seed = new Random();
int num1 = seed.nextInt(10)+1;
int num2 = seed.nextInt(10)+1;
lblNum1.setText(String.valueOf(num1));
lblNum2.setText(String.valueOf(num2));
sum_total = num1 + num2;

btnCheck
int user_guess;
user_guess = Integer.valueOf(txtAnswer.getText());

if(user_guess == sum_total){
	num_right++;
	lblRight.setText(String.valueOf(num_right));
}
else
{
	num_wrong++;
	lblWrong.setText(String.valueOf(num_wrong));
}