cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

random nextboolean :(

Former Member
0 Likes
272

Hi I have a question regarding this method.. Someone told me that I could generate a random - or + sign with this method but since I'm very new to java programming, I'd like a little help or maybe an example as to how I can achieve it, the example that I'm working on right now is generating two numbers and arithmetic operator (-/+) randomly and then putting them togetherlike say..

1-1 = ?

or 2+2 = ?

I just want to know how can I generate - or + randomly..

I'm going crazzzzzzzyyyyyyyy over this please help guys

View Entire Topic
prashil
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Zumah,

Whatever i understood by your requirement,

i suggest to use random number generator, the number will be in the range of (0.0-0.99)

add a condition like if genrated number is greater than 0.5, then use '+' operator else use '-' operator.

Hope this will help you to find the solution!!!!

Regards,

Prashil