-
-
Save anonymous/fe1a0bc5971749e89a60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "\n\nAre you ready for some math?\n\n" | |
puts "How many questions do you want?\n\n" | |
i=gets.chomp | |
i=i.to_i | |
puts"\n\n" | |
correct_answers=0 | |
wrong_answers=0 | |
start_time=Time.new | |
i.times do | |
num1=rand(10) | |
num2=rand(10) | |
puts "#{num1}*#{num2} " | |
answer=gets.chomp | |
correct_answer=num1*num2 | |
if answer.to_i==correct_answer | |
puts "\nCorrect!\n\n" | |
correct_answers+=1 | |
else | |
puts "\nWRONG!!! \nThe correct answer is #{correct_answer}\n\n" | |
wrong_answers+=1 | |
end | |
end | |
percent_correct=(correct_answers.to_f/i)*100 | |
end_time=Time.new | |
how_long=end_time-start_time | |
if i!=0 | |
puts "\n\nYou had #{correct_answers} correct answers and #{wrong_answers} wrong answers!\n\nYou answered #{percent_correct}% of the questions correctly and it took you #{Time.at(how_long).utc.strftime("%H:%M:%S")} (hours/mins/secs) to answer all the questions!\n\n" | |
case percent_correct | |
when 100..100 | |
puts"You did an amazing job and answered all questions correctly!!! You are THE BEST!!!" | |
when 80..99 | |
puts "You did a great job, keep up the good work!" | |
when 50..79 | |
puts "You did a good job, but you should try and improve your multiplication skills." | |
else | |
puts "You did not do very well...You should study your multiplication table more and try again." | |
end | |
else | |
puts"\n\nMaybe next time...Goodbye!" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment