Skip to content

Instantly share code, notes, and snippets.

@iheartkode
Created July 9, 2014 18:57
Show Gist options
  • Save iheartkode/b845589f050ee239a72b to your computer and use it in GitHub Desktop.
Save iheartkode/b845589f050ee239a72b to your computer and use it in GitHub Desktop.
allergens = {
"eggs" => 1,
"peanuts" => 2 ,
"shellfish" => 4,
"strawberries" => 8,
"tomatoes" => 16,
"chocolate" => 32,
"pollen" => 64,
"cats" => 128,
}
def add(alergen1, allergen2)
total = alergen1.to_i + allergen2.to_i
puts "Your Allergy score is: #{total}"
end
puts ":::::::Here is the list of allergens:::::::"
allergens.each do |allergy|
puts allergy
end
puts "Enter two allergen numbers"
puts "First number"
num1 = gets.chomp
puts "Second number"
num2 = gets.chomp
add(num1,num2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment