First you should declare a variable for the correct and the incorrect answers, you can do it like this:
code:
$correct_answers = 0
$incorrect_answers = 0
puts "Hello! Welcome to my survey!"
# FIRST QUESTION
puts "First question: What is my favorite color?"
answer1 = gets.chomp
if answer1 == "Black"
puts "Correct!"
$correct_answers += 1
elsif answer1 == "black"
puts "Correct!"
$correct_answers += 1
else
puts "Incorrect!"
$incorrect_answers += 1
end...
Then at the end of each answer, if that's right you add +1 to the $correct_answers value, if it's wrong... well, you got it.
PS: This is not the best way to handle it, but since you seem to be starting, go for it and play with this method for a while.
Edit: I forgot your final request, if you want to print the result just add this to your code
code:
puts "You have #$correct_answers answers right!"
Last edited by IIInsanEEE; May 1, 2015 at 06:35 PM.