I have a simple method which will generate an addition problem, get the users answer from the command line, then output if they are right or wrong, however it always defaults to the "incorrect" condition and I can't get it to work
def questionPromt
firstNumber = rand(20)
secondNumber = rand(20)
equation = firstNumber + secondNumber
puts "What is #{firstNumber} + #{secondNumber} ?"
useranswer = gets.chomp
if equation == useranswer
puts "good job "
else
puts "wrong answer"
end
end
Help appreciated.
Aucun commentaire:
Enregistrer un commentaire