Jump to content

Quiz


JustinReno
 Share

Recommended Posts

I'm creating a simple quiz app but, if you get a question wrong, it doesn't subtract one from the score: Can anyone help? I've tried some different things but nothing works.

CODE

Global $Score = 100

$Start = Msgbox(36, "Quiz", "Here, is a fun little quiz. Do you want to play?")

If $Start = 6 Then

_Questions ()

EndIf

Func _Questions()

$Q1 = Inputbox("Quiz", "What is 2+2?")

$Q2 = Inputbox("Quiz", "What is 2-2?")

$Q3 = Inputbox("Quiz", "What is 2+2?")

If NOT $Q1 = "4" Then

$Score = $Score = -1

EndIf

If NOT $Q2 = "0" Then

$Score = $Score = -1

EndIf

If Not $Q3 = "4" Then

$Score = $Score = -1

EndIf

Msgbox(64, "Quiz", "Your Done! Your score is: "&$Score&"")

EndFunc

Link to comment
Share on other sites

  • Moderators

Try this...

Global $Score = 100

$Start = MsgBox(36, "Quiz", "Here, is a fun little quiz. Do you want to play?")
If $Start = 6 Then
    _Questions()
EndIf

Func _Questions()
    $Q1 = InputBox("Quiz", "What is 2+2?")
    $Q2 = InputBox("Quiz", "What is 2-2?")
    $Q3 = InputBox("Quiz", "What is 2+2?")
    If $Q1 <> "4"  Then
        $Score -= 1
    EndIf
    If $Q2 <> "0"  Then
        $Score -= 1
    EndIf
    If $Q3 <> "4"  Then
        $Score -= 1
    EndIf
    MsgBox(64, "Quiz", "Your Done! Your score is: " & $Score & "")
EndFunc   ;==>_Questions
Link to comment
Share on other sites

Heres a way to do it I added a part that calculates the % score

$Start = Msgbox(36, "Quiz", "Here, is a fun little quiz. Do you want to play?")
If $Start = 6 Then
_Questions()
EndIf

Func _Questions()
$QNum = 4; Number of questions
$Score = $QNum
$Q1 = Inputbox("Quiz", "What is 2+2?")
$Q2 = Inputbox("Quiz", "What is 2-2?")
$Q3 = Inputbox("Quiz", "What is 2+2?")
$Q4 = Inputbox("Quiz", "What is 3+3?")
If $Q1 = "4" Then
Else
$Score -= 1
EndIf
If $Q2 = "0" Then
Else
$Score -= 1
EndIf
If $Q3 = "4" Then
Else
$Score -= 1
EndIf
If $Q4 = "6" Then
Else
$Score -= 1
EndIf
$Score /= $QNum
$Score *= 100
Msgbox(64, "Quiz", "Your Done! Your score is: "&$Score&"%")
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...