Guest User

Untitled

a guest
Jun 7th, 2013
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.80 KB | None | 0 0
  1. #BMI class for learning purposes by Victor Vadelius
  2. #2013-06-07
  3.  
  4. class Bmi
  5.     print ("What's your name?")
  6.    name = gets.chomp
  7.     print ("How tall are you? (In centimeters)")
  8.   height = gets.to_f
  9.     print ("How much do you weigh? (In kilograms)")
  10.   weight = gets.to_f
  11.     print ("How old are you?")
  12.   age = gets.chomp
  13.  
  14.   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.")
  15.     bmi =  weight / (height*height)
  16.   print ("\n Your BMI is: #{10000*bmi}")
  17.   if bmi <= 19
  18.     print ("You are underweight, EAT MORE!")
  19.   elsif bmi > 19 && bmi <= 25
  20.     print ("You are in the ideal weight range.")
  21.   elsif bmi > 25
  22.     print ("You are overweight, go exercise!")
  23.   else
  24.     print ("Something went terribly wrong")
  25.   end
  26. end
Advertisement
Add Comment
Please, Sign In to add comment