This blog no longer exists.
You will be redirected to something cool.

Friday, October 29, 2010

Quiz Program (Loops)

This one was difficult for me, but not as much as the last time I encountered loops. I think after a few more small programs with loops I'll feel more comfortable with this. I created a quiz about me. Feel free to run it and take it. (It's in Ruby.)


puts( '     <(^.^)> LITTLE KNOWN FACTS O\' MELANIE <(^.^)>')
puts
puts( 'To play, select the letter that corresponds with your answer
then press return')
answer = ''

while answer != 'c'
puts( '#1 Gym class sux. How would Melanie get out of running laps in Elem school?')
puts
puts( 'a. She got a doctors note')
puts( 'b. She refused')
puts( 'c. She hid')
puts( 'd. She got extra help in another subject instead of going to gym')
answer = gets.chomp.downcase
end

puts( 'Correct!')

answer = ''

while answer != 'b'
puts( '#2 Melanie has a scar on her knee from kindergarten. How did she get it?')
puts
puts( 'a. She fell off the jungle gym')
puts( 'b. She was running in flip flops and tripped')
puts( 'c. She got beat up')
puts( 'd. Her brother threw something at her')
answer = gets.chomp.downcase
end

puts( 'Correct!')

answer = ''

while answer != 'a'
puts( '#3 Melanie failed ONE class in high school. Which was it?')
puts
puts( 'a. government')
puts( 'b. business services technology')
puts( 'c. geometry')
puts( 'd. art')
answer = gets.chomp.downcase
end

puts( 'Correct!')

answer = ''

while answer != 'c'
puts( '#4 Melanie is l337 fail at sports. Which sport did she play in high school?')
puts
puts( 'a. basketball')
puts( 'b. cheerleading')
puts( 'c. track')
puts( 'd. volleyball')
answer = gets.chomp.downcase
end

puts( 'Correct!')

answer = ''

while answer != 'b'
puts( '#5 Melanie went on a family vacation when she was 10. Where did she go?')
puts
puts( 'a. Virginia Beach, VA')
puts( 'b. Chattanooga, TN')
puts( 'c. Groton, CT')
puts( 'd. Tell City, IN')
answer = gets.chomp.downcase
end

puts( 'Correct!')

0 comments: