Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: Re: Logical Operators

by myocom (Deacon)
on May 26, 2001 at 10:19 UTC ( [id://83477]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Logical Operators
in thread Logical Operators

Certainly.

Each time an answer is given, see if it's right, then increment a counter. At the end, you'll have the number of right answers. The code below reads very much like that sentence:

# The code has already asked a question at this point # ("What is the answer to Life, the Universe, and Everything"). # The user has put in his/her answer. # The program has stored it in a scalar, $answer. if ($answer == 42) { $rightanswers++; } # Put that sort of logic in your question/answer loop, # then you can end with something like this: if ($rightanswers == 25) { print "You got all of the questions right! You win!\n"; } elsif ($rightanswers > 20) { print "You got almost all of the questions right. Not bad!\n"; } elsif ($rightanswers > 10) { print "You could've done better...\n"; } elsif ($rightanswers > 1) { print "You did quite poorly...\n"; } else { print "Were you even reading the questions...?\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://83477]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-03-29 07:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found