none
Math question program RRS feed

  • 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

Answers

  • Here is an simple program:

    stop=0
    While stop=0
      typ=Math.GetRandomNumber(3)
      If typ=1 Then  ''addition (1:20)
        var1=Math.GetRandomNumber(20)
        var2=Math.GetRandomNumber(20)
        answer=var1+var2
        typ=" + "
      elseif typ=2 then  ' subtraction (1:20 pos. answer)
        var1=Math.GetRandomNumber(20)
        var2=var1-Math.GetRandomNumber(var1)+1
        answer=var1-var2
        typ=" - "
      Else        'multiply  (1:10)
        var1=Math.GetRandomNumber(10)
        var2=Math.GetRandomNumber(10)
        answer=var1*var2
        typ=" * "
      EndIf
      TextWindow.Write(" "+var1+typ+var2+" ? ")
      ans=Textwindow.Read()
      If ans="" Then
        stop=1
      else
        
        TextWindow.CursorTop=TextWindow.CursorTop-1
        TextWindow.CursorLeft=20
        if ans=answer then
          TextWindow.ForegroundColor="green"
          TextWindow.WriteLine("     OK")
        Else
          TextWindow.ForegroundColor="red"
          TextWindow.WriteLine("  error")
        endif
        TextWindow.ForegroundColor="gray"
      EndIf
    EndWhile
      
    Can easily be adapted to your wishes.


    Jan [ WhTurner ] The Netherlands

    Thursday, November 5, 2015 6:56 PM
    Answerer

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)

    Answer an interesting question? Create a wiki article about it!

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

    stop=0
    While stop=0
      typ=Math.GetRandomNumber(3)
      If typ=1 Then  ''addition (1:20)
        var1=Math.GetRandomNumber(20)
        var2=Math.GetRandomNumber(20)
        answer=var1+var2
        typ=" + "
      elseif typ=2 then  ' subtraction (1:20 pos. answer)
        var1=Math.GetRandomNumber(20)
        var2=var1-Math.GetRandomNumber(var1)+1
        answer=var1-var2
        typ=" - "
      Else        'multiply  (1:10)
        var1=Math.GetRandomNumber(10)
        var2=Math.GetRandomNumber(10)
        answer=var1*var2
        typ=" * "
      EndIf
      TextWindow.Write(" "+var1+typ+var2+" ? ")
      ans=Textwindow.Read()
      If ans="" Then
        stop=1
      else
        
        TextWindow.CursorTop=TextWindow.CursorTop-1
        TextWindow.CursorLeft=20
        if ans=answer then
          TextWindow.ForegroundColor="green"
          TextWindow.WriteLine("     OK")
        Else
          TextWindow.ForegroundColor="red"
          TextWindow.WriteLine("  error")
        endif
        TextWindow.ForegroundColor="gray"
      EndIf
    EndWhile
      
    Can easily be adapted to your wishes.


    Jan [ WhTurner ] The Netherlands

    Thursday, November 5, 2015 6:56 PM
    Answerer