Skip to content

Instantly share code, notes, and snippets.

@hopbit
Created February 23, 2016 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hopbit/0fd84369026e9e84255f to your computer and use it in GitHub Desktop.
Save hopbit/0fd84369026e9e84255f to your computer and use it in GitHub Desktop.
This simple Ruby script calculates HR Max based on formula created by Sally Edwards.
# calculates maximum heart rate for woman
# formula by sally edwards
def hr_max_woman(age, weight)
return 210 - 0.5 * age - 0.022 * weight
end
# calculates maximum heart rate for man
# formula by sally edwards
def hr_max_man(age, weight)
return 210 - 0.5 * age - 0.022 * weight + 4
end
puts """
This simple script calculates HR Max (maximum heart rate)
for woman & man based on formula prepared by Sally Edwards
"""
print "Type your age: "
user_age = $stdin.gets.chomp.to_f
print "Type your weight: "
user_weight = $stdin.gets.chomp.to_f
man_hr_max = hr_max_man(user_age, user_weight)
woman_hr_max = hr_max_woman(user_age, user_weight)
puts """
If You're a woman, then Your HR Max is #{woman_hr_max}.
If Your're a man, then Your HR Max is #{man_hr_max}.
"""
# Links:
# * http://bieganie.pl/?show=1&cat=15&id=411
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment