I’m trying to adapt an integers practice game by Mr. Chow for a division practice. How can I adapt the code so that the problems are all integer answers?
If that works, can I change the text students see so that it looks like a fraction instead of using a forward slash?
This division:
r = randomGenerator(in.submitCount)
r1 = r.int(-100,100)
r2 = r.int(-10,10)
value = numericValue("{r1}/{r2}")
and making this look like a fraction?
${r1}/${r2}
Instead, of setting the numerator and denominator, r1 and r2, set r2and the value:
den=r.int(-10,10)
quotient=r.int(-10,10)
num=numericValue("${den}*${quotient}")
fracLatex=`\frac{ ${num} }{ ${den} }`
We have a tendency to think about our problems in how we’d solve them, which isn’t always useful when coding.
That totally made sense thank you! Is there a way to make it so the denominator can’t be zero?
Might need to play with it a little, but something like this:
den=numericValue("${r.int(1,10)}*(-1)^{ ${r.int(0,1)} }")