none
True or False Quiz Help RRS feed

  • Question

  • Earlier this week I started to make a(text.window based) true or false quiz that has 5 questions and counts up the scores and displays them at the end, however I can't seem to get it working.

    Please would someone be able to help with this?

    Monday, February 8, 2016 8:26 AM

Answers

  • firstly, Variables can't just be numbers. So when you have  

    5 = TextWindow.Read()

    It needs to be V5 or Var5 or Q5 or somthing. It can't be just 5. The same goes for all the other questions.

    You also need to say 

    score = score + N2

    instead of 

    score + N2

    also, you need and EndIf after the score checker. 

    Here is the modified code:

    begin:
    TextWindow.WriteLine("Welcome to My Quiz!")
    Program.Delay(1600)
    TextWindow.WriteLine("I will ask you 5 questions about the movie madagascar")
    TextWindow.WriteLine("    ... And you will simply anwser 'true' or 'false'")
    Program.Delay(1600)
    score = 1
    N1 = 1
    N2 = 2
    N3 = 3
    N4 = 4
    N5 = 5
    TextWindow.WriteLine("Question 1. ")
    Q1 = TextWindow.Read()
    If Q1 = "true" Then
      score = score + N1
      EndIf
    
    TextWindow.WriteLine("Question 2. ")
    Q2 = TextWindow.Read()
    If Q2 = "true" Then
      score = score + N2
      EndIf
    
    TextWindow.WriteLine("Question 3. ")
    Q3 = TextWindow.Read()
    If Q3 = "true" Then
      score = score + N3
      EndIf
    TextWindow.WriteLine("Question 4. ")
    Q4 = TextWindow.Read()
    If Q4 = "true" Then
      score = score + N4
      EndIf
    TextWindow.WriteLine("Question 5. ")
    Q5 = TextWindow.Read()
    If Q5 = "true" Then
      score = score + N5
      EndIf
      
      
      If score = 16 Then
        TextWindow.WriteLine("Well done, You have got 5 out of 5!")
        EndIf
    Goto begin
    


    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

    Monday, February 8, 2016 6:23 PM
    Answerer
  • You cannot have variables called 1 or 2 ...  Variable names should start with a letter or _ (underscore)

    So 1= TextWindowRead()  should be e.g.  var1=TextWindowRead()


    Jan [ WhTurner ] The Netherlands


    Monday, February 8, 2016 6:24 PM
    Answerer

All replies

  • What is the problem? Do you get syntax errors when yoou try to run the program? Do you get the wromng answers?

    We cannot help you if we do not know your program.


    Jan [ WhTurner ] The Netherlands

    Monday, February 8, 2016 2:26 PM
    Answerer
  • begin:
    TextWindow.WriteLine("Welcome to My Quiz!")
    Program.Delay(1600)
    TextWindow.WriteLine("I will ask you 5 questions about the movie madagascar")
    TextWindow.WriteLine("    ... And you will simply anwser 'true' or 'false'")
    Program.Delay(1600)
    score = 1
    N1 = 1
    N2 = 2
    N3 = 3
    N4 = 4
    N5 = 5
    TextWindow.WriteLine("Question 1. ")
    1 = TextWindow.Read()
    If 1 = "true" Then
      score + N1
      EndIf

    TextWindow.WriteLine("Question 2. ")
    2 = TextWindow.Read()
    If 2 = "true" Then
      score + N2
      EndIf

    TextWindow.WriteLine("Question 3. ")
    3 = TextWindow.Read()
    If 3 = "true" Then
      score + N3
      EndIf
    TextWindow.WriteLine("Question 4. ")
    4 = TextWindow.Read()
    If 4 = "true" Then
      score + N4
      EndIf
    TextWindow.WriteLine("Question 5. ")
    5 = TextWindow.Read()
    If 5 = "true" Then
      score + N5
      EndIf
     
     
      If score = 16 Then
        TextWindow.WriteLine("Well done, You have got 5 out of 5!")

    Goto begin

    **********************************************************

    That was my program so far, however I can't seem to get a score checker working.

    Would you be able to help with this?


    • Edited by Enstroe Monday, February 8, 2016 6:05 PM
    Monday, February 8, 2016 5:59 PM
  • firstly, Variables can't just be numbers. So when you have  

    5 = TextWindow.Read()

    It needs to be V5 or Var5 or Q5 or somthing. It can't be just 5. The same goes for all the other questions.

    You also need to say 

    score = score + N2

    instead of 

    score + N2

    also, you need and EndIf after the score checker. 

    Here is the modified code:

    begin:
    TextWindow.WriteLine("Welcome to My Quiz!")
    Program.Delay(1600)
    TextWindow.WriteLine("I will ask you 5 questions about the movie madagascar")
    TextWindow.WriteLine("    ... And you will simply anwser 'true' or 'false'")
    Program.Delay(1600)
    score = 1
    N1 = 1
    N2 = 2
    N3 = 3
    N4 = 4
    N5 = 5
    TextWindow.WriteLine("Question 1. ")
    Q1 = TextWindow.Read()
    If Q1 = "true" Then
      score = score + N1
      EndIf
    
    TextWindow.WriteLine("Question 2. ")
    Q2 = TextWindow.Read()
    If Q2 = "true" Then
      score = score + N2
      EndIf
    
    TextWindow.WriteLine("Question 3. ")
    Q3 = TextWindow.Read()
    If Q3 = "true" Then
      score = score + N3
      EndIf
    TextWindow.WriteLine("Question 4. ")
    Q4 = TextWindow.Read()
    If Q4 = "true" Then
      score = score + N4
      EndIf
    TextWindow.WriteLine("Question 5. ")
    Q5 = TextWindow.Read()
    If Q5 = "true" Then
      score = score + N5
      EndIf
      
      
      If score = 16 Then
        TextWindow.WriteLine("Well done, You have got 5 out of 5!")
        EndIf
    Goto begin
    


    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

    Monday, February 8, 2016 6:23 PM
    Answerer
  • You cannot have variables called 1 or 2 ...  Variable names should start with a letter or _ (underscore)

    So 1= TextWindowRead()  should be e.g.  var1=TextWindowRead()


    Jan [ WhTurner ] The Netherlands


    Monday, February 8, 2016 6:24 PM
    Answerer
  • Thank you very much, this helped a lot!
    Monday, February 8, 2016 6:37 PM
  • Thank you for pointing out my mistakes!
    Monday, February 8, 2016 6:38 PM