Class: A15z8myName::A15z8myName

Inherits:
Object
  • Object
show all
Defined in:
lib/a15z8my_name.rb

Instance Method Summary collapse

Instance Method Details

#calcBmi(h, w) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/a15z8my_name.rb', line 5

def calcBmi(h, w)
  begin
    if h.class() == Float
      exit(1)
    end
  rescue SystemExit
    $stderr.puts "input your height as cm"
    return false
  end

  w_h = h.to_f / 100
  
  bmi = w / (w_h**2)
  best_weight = (w_h**2) * 22

  $stdout.print "Your BMI : ", bmi.round(2), "\n"
  $stdout.print "Your Best Weight : ", best_weight.round(2), "\n"
end