+ 1

How to do random action with numbers?

Hello friends, nice to read you. How to do this? (it's work like string, but how to make the equation?) https://code.sololearn.com/WmsdTkZ9i95E/?ref=app

14th Nov 2017, 4:20 PM
Bogdan Saliuk
Bogdan Saliuk - avatar
2 ответов
+ 3
the +-×÷ you set is characters, cannot directly use for math operators. Use switch operator to help you choose the correct math operation.
14th Nov 2017, 4:37 PM
Calviղ
Calviղ - avatar
+ 2
Use if..else to evaluate which random operator string returned, then do the math as necessary, depending on the operator returned. if(action==="+") // add a & b ...
14th Nov 2017, 4:34 PM
Ipang