...

Problem with Java

kuskyboy
03-31-2005, 01:10 PM
Hi,

I am writing a rogram that generates random maths questions for primary schools, but im having a problem finding out how to select one of the following characters at random (+ - * /). PLease can you help? :)

Kuskyboy

shmoove
04-01-2005, 09:34 AM
There are many ways to solve that. Here is one:

switch (someRandomIntegerBetweenZeroAndThree) {
case 0:
operator = '+';
break;
case 1:
operator = '-';
break;
case 2:
operator = '*';
break;
case 3:
operator = '/';
break;
}


shmoove

kuskyboy
04-01-2005, 03:17 PM
thanks very much for that.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum