I am making an addition math game, which has two random variable on it.
I made this code=
but when i compile it, the "hasil" variable display wrong result.
variable a is displaying 8
variable b is displaying 2
but the variable hasil is displaying 40.
what should i do to save the random number so "hasil" can display the correct answer?
Thank you
int a=Greenfoot.getRandomNumber(9);
int b=Greenfoot.getRandomNumber(9);
int hasil=a+b;



i declared it on the "makanan"
penjumlah1= variable a
penjumlah2=variable b
hasil = result
and i located it outside the act method :) is this wrong?