Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
lottery1 = rand(10)
lottery2 = rand(10)
lottery3 = rand(10)
pick1 = 10
pick2 = 10
pick3 = 10
numberMatch = 0
while pick1 >9
puts( 'Choose your 1st lottery number. Pick a number 0-9: ')
pick1 = gets.chomp.to_i
end
while pick2 >9
puts( 'Choose your 2nd lottery number. Pick a number 0-9: ')
pick2 = gets.chomp.to_i
end
while pick3 >9
puts( 'Choose your 3rd lottery number. Pick a number 0-9: ')
pick3 = gets.chomp.to_i
end
puts "You chose #{pick1}, #{pick2}, and #{pick3}."
puts "The winning numbers are #{lottery1}, #{lottery2}, and #{lottery3}."
if pick1 != lottery1 && pick1 != lottery2 && pick1 != lottery3
numberMatch = 0
end
if pick1 == lottery1 && pick2 == lottery2 && pick3 == lottery3
numberMatch = 4
lottery1 = 10
lottery2 = 10
lottery3 = 10
end
if pick1 == lottery1
numberMatch = numberMatch + 1
lottery1 = 10
elsif pick1 == lottery2
numberMatch = numberMatch + 1
lottery2 = 10
elsif pick1 == lottery3
numberMatch = numberMatch + 1
lottery3 = 10
end
if pick2 == lottery1
numberMatch = numberMatch + 1
lottery1 = 10
elsif pick2 == lottery2
numberMatch = numberMatch + 1
lottery2 = 10
elsif pick2 == lottery3
numberMatch = numberMatch + 1
lottery3 = 10
end
if pick3 == lottery1
numberMatch = numberMatch + 1
lottery1 = 10
elsif pick3 == lottery2
numberMatch = numberMatch + 1
lottery2 = 10
elsif pick3 == lottery3
numberMatch = numberMatch + 1
lottery3 = 10
end
if numberMatch == 0
puts
puts 'You have no matches'
puts 'Your total prize money is $0.'
elsif numberMatch == 1
puts
puts 'You have one match'
puts 'Your total prize money is $10.'
elsif numberMatch == 2
puts
puts 'You have two matches'
puts 'Your total prize money is $100.'
elsif numberMatch == 3
puts
puts 'You have three matches'
puts 'Your total prize money is $1000.'
elsif numberMatch == 4
puts
puts 'You won the jackpot!'
puts 'Your total prize money is $1,000,000!!!'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment