Hello all,
For the record I am a complete java novice.
I have to write a program to generate/output to screen 10 simple maths question and output a final score . The question is as follows
Random number, Random operator (+ or -) random number.
I have written the program but cannot make the random operator work. Can anyone help?
My code.
a = myRandom.nextIn t(8) +11;//generates random number
b = myRandom.nextIn t(8) +1;//generates 2nd random number
if(b<4)//this code sets random operator + or -
{
t='-'; // t is the random operator
}
else
{
t='+';
}
System.out.prin t("Question "+p+": "+((a+t+b)+ "= ? "));//prints question to screen
Thanks
For the record I am a complete java novice.
I have to write a program to generate/output to screen 10 simple maths question and output a final score . The question is as follows
Random number, Random operator (+ or -) random number.
I have written the program but cannot make the random operator work. Can anyone help?
My code.
a = myRandom.nextIn t(8) +11;//generates random number
b = myRandom.nextIn t(8) +1;//generates 2nd random number
if(b<4)//this code sets random operator + or -
{
t='-'; // t is the random operator
}
else
{
t='+';
}
System.out.prin t("Question "+p+": "+((a+t+b)+ "= ? "));//prints question to screen
Thanks
Comment