Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #BMI class for learning purposes by Victor Vadelius
- #2013-06-07
- class Bmi
- print ("What's your name?")
- name = gets.chomp
- print ("How tall are you? (In centimeters)")
- height = gets.to_f
- print ("How much do you weigh? (In kilograms)")
- weight = gets.to_f
- print ("How old are you?")
- age = gets.chomp
- printf ("Summary so far: Your name is #{name}. You are #{height} cm's tall & you weigh #{weight} kg's. You are #{age} years of age.")
- bmi = weight / (height*height)
- print ("\n Your BMI is: #{10000*bmi}")
- if bmi <= 19
- print ("You are underweight, EAT MORE!")
- elsif bmi > 19 && bmi <= 25
- print ("You are in the ideal weight range.")
- elsif bmi > 25
- print ("You are overweight, go exercise!")
- else
- print ("Something went terribly wrong")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment