Instead of having to do this on paper and a calculator I decided to make a sweet Perl script to do this for me. Any comments are welcomed since I don't claim to be a Perl expert by any means. Enjoy!

#!/usr/bin/perl use strict; use warnings; use 5.010; # BMI Calculator For Men # Created by: Jamie Newton # 12-11-10 Formula Cited Sources # The Body Sculpting Bible for Men, Hugo Rivera & James Villepique # Introduction ------------------------------------------------------- +------------- say "BMI CALCULATOR FOR MEN\n\nHello, this tool will calculate your to +tal fat percentage."; # Declare Variables to be used in Script my($current_weight); my($waist_girth); my($BodyShape); # Collect User's Weight ---------------------------------------------- +------------- do { say "Please enter your current weight >"; chomp($current_weight = <STDIN>); } until ($current_weight =~ /^[0-9]+$/); # Collect User's Waist Size ------------------------------------------ +------------- do { say "Please enter your waist girth (measured at the umbilicus) + >"; chomp($waist_girth = <STDIN>); } until ($waist_girth =~ /^-{0,1}\d*\.{0,1}\d+$/); # Get Lean Body Weight (as if you had no fat at all) ----------------- +-------------- my $Result1 = ($current_weight * 1.082) + 94.42; my $Result2 = $Result1 - ($waist_girth * 4.15); # Round to 2 decimal Places ------------------------------------------ +-------------- my $BodyFatPercentage = sprintf "%.2f"; # Find Out The Total Body Fat Percentage ----------------------------- +-------------- chomp($BodyFatPercentage = (($current_weight-$Result2) * 100) / $curre +nt_weight); # Determine if the User is Underweight, Healthy, Overweight, or Obese if ($BodyFatPercentage < 18) { $BodyShape = "Underweight"; } elsif ($BodyFatPercentage > 17 && $BodyFatPercentage < 25) { $BodyShape = "Healthy"; } elsif ($BodyFatPercentage > 24 && $BodyFatPercentage < 30) { $BodyShape = "Overweight"; } elsif ($BodyFatPercentage >= 30) { $BodyShape = "Obese"; } #Display BF % to User print "\nYour Total Body Fat % is "; print sprintf("%.2f", $BodyFatPercentage); print "%\n\n"; print "This indicates that you are $BodyShape."; print "\n\n"; print "Extra: Your weight without any fat = $Result2"; print "\n\n\n\n\n";

The early bird gets the worm but the second mouse gets the cheese.
pretendeavor

In reply to Body Mass Index Calculator by naildownx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.