Created
April 12, 2017 12:32
-
-
Save 4d47/22ac4ee70b178bfeb1e4e52862294e84 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 0.25 500$ | |
# 2000, | |
use IO::Prompt; | |
# http://www.builtlean.com/2010/05/04/ideal-body-weight-formula-how-to-calculate-your-ideal-weight/ | |
sub postfix:<%>(Numeric $x --> Numeric) { | |
$x / 100 | |
} | |
my $body-weight = ask 'Weight:', :type(Num); | |
my $body-fat-precentage = (ask 'Fat percentage:', :type(Num))%; | |
my $desired-body-fat-percentage = (ask 'Target fat percentage:', 25, :type(Num))%; | |
my $lean-body-mass = | |
$body-weight - ($body-weight * $body-fat-precentage); | |
my $ideal-body-weight = | |
$lean-body-mass / (1 - $desired-body-fat-percentage); | |
say 'Target weight: ' ~ $ideal-body-weight; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment