Math question program

• Question

• Has anyone an example of a program which ask a seres of maths questions using add, subract and multiply?
Friday, December 19, 2014 10:29 AM

• Here is an simple program:

```stop=0
While stop=0
typ=Math.GetRandomNumber(3)
var1=Math.GetRandomNumber(20)
var2=Math.GetRandomNumber(20)
typ=" + "
elseif typ=2 then  ' subtraction (1:20 pos. answer)
var1=Math.GetRandomNumber(20)
var2=var1-Math.GetRandomNumber(var1)+1
typ=" - "
Else        'multiply  (1:10)
var1=Math.GetRandomNumber(10)
var2=Math.GetRandomNumber(10)
typ=" * "
EndIf
TextWindow.Write(" "+var1+typ+var2+" ? ")
If ans="" Then
stop=1
else

TextWindow.CursorTop=TextWindow.CursorTop-1
TextWindow.CursorLeft=20
TextWindow.ForegroundColor="green"
TextWindow.WriteLine("     OK")
Else
TextWindow.ForegroundColor="red"
TextWindow.WriteLine("  error")
endif
TextWindow.ForegroundColor="gray"
EndIf
EndWhile
```

Jan [ WhTurner ] The Netherlands

Thursday, November 5, 2015 6:56 PM

All replies

• This is a little odd that this December post is showing up now. Anyway, Robert, are you still curious?

You know, you'd think this would be easy to find. It might be in one of our monthly Small Basic Challenges.

Thanks!

Ed Price, Azure & Power BI Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

Thursday, November 5, 2015 3:53 AM
• Here is an simple program:

```stop=0
While stop=0
typ=Math.GetRandomNumber(3)
var1=Math.GetRandomNumber(20)
var2=Math.GetRandomNumber(20)
typ=" + "
elseif typ=2 then  ' subtraction (1:20 pos. answer)
var1=Math.GetRandomNumber(20)
var2=var1-Math.GetRandomNumber(var1)+1
typ=" - "
Else        'multiply  (1:10)
var1=Math.GetRandomNumber(10)
var2=Math.GetRandomNumber(10)
typ=" * "
EndIf
TextWindow.Write(" "+var1+typ+var2+" ? ")
If ans="" Then
stop=1
else

TextWindow.CursorTop=TextWindow.CursorTop-1
TextWindow.CursorLeft=20
TextWindow.ForegroundColor="green"
TextWindow.WriteLine("     OK")
Else
TextWindow.ForegroundColor="red"
TextWindow.WriteLine("  error")
endif
TextWindow.ForegroundColor="gray"
EndIf
EndWhile
```