locked
Little program I wrote :D might wanna check it out. RRS feed

  • General discussion

  • As a 12 year old. I'm in the process of studying my multiplication facts. Bored off my mind, I came across the program small basic. In the attempt to create the best of both worlds, I think i came darn close.

    Basically you give it a factor, lets use 5 as an example. The program then gets a random number and displays the problem for ex. 5x7. You would then type out the answer and hit return. If it's correct it says so. If it is wrong... well it also says so. I know you guys don't need this, but I think it would be nice to have a look.

    Here is my code

    TextWindow.Title = "Multiplication Quiz"
    TextWindow.WriteLine("Enter in the multiple for this quiz")
    Multiple = TextWindow.Read()
    
    NewNum:
    RandomNum = Math.GetRandomNumber(12)
    
    two:
    TextWindow.WriteLine(Multiple + "x" + RandomNum)
    Ans1 = TextWindow.Read()
    
    Anwser = Multiple * RandomNum
    
    If (Multiple * RandomNum) = Ans1 Then
     TextWindow.WriteLine("CORRECT " + Multiple + "x" + RandomNum + "= " + Anwser )
     
    Else
     
     TextWindow.WriteLine("Wrong " + Multiple + "x" + RandomNum + "= " + Anwser )
     goto NewNum
     
     Goto two
    
    EndIf
    
    goto NewNum

    PS: I'm currently on 2.4 in the Small Basic tutorials. So any feedback would be great!

    Thursday, April 14, 2011 4:50 AM

All replies

  • The12YearOldCoder, this is a great program you've written. If you'd like, you could add a TextWindow.Pause() right after you write if the answer is correct or incorrect. Not really necessary, but it may be easier to see.
    ~~AirWaves!!~~
    Thursday, April 14, 2011 4:21 PM
  • Like Airwaves said, well done.

    Suggestions:

    1] Use TextWindow.ReadNumber() when the user must enter a number, a non-number will not be accepted if you use this.

    2] You don't need the 'GoTo two' after the Else (if the user gets it wrong) - this can never be done since there is a 'GoTo NewNum' immediately before it - if you want the user to get another go at the same problem by using the 'GoTo two' line, then remove the 'GoTo NewNum'.

    Thursday, April 14, 2011 8:05 PM
  • 2 ways I programmed, in Applesoft basic back in the 80's ;

    1) Bored:
    I would mostly make programs that look like existing programs, like the old Atari's "Dungeon" game, or "Asteriods".

    2) Necessity;
    In highschool, I hated having to write out the complete answer to an algebra problem when I could figure it out and give the correct end answer without having to use up 1/2 to a page, or more, to show how I figured out the problem.  Not to mention my hand got tired. So I wrote a program that would print out the answer for me.  At first the teacher excepted the homework from this program because I explained that the computer knows basic math but not write out the problems as required in Algebra, and if I didn't know how figure out the answer, then the answers the computer generated would be wrong.
    Then my class mates complained, saying I was cheating by using the computer, so he told me I had to start writing it out.

    Monday, April 18, 2011 2:47 PM