Skip to content

Instantly share code, notes, and snippets.

@steverhall
Last active March 26, 2019 14:30
Show Gist options
  • Save steverhall/dae41590f99569f5103f027b563dbac1 to your computer and use it in GitHub Desktop.
Save steverhall/dae41590f99569f5103f027b563dbac1 to your computer and use it in GitHub Desktop.
Body Mass Index Calculation
using System;
namespace HealthCorp.Core
{
public class BMI
{
private const double KILOGRAMS_PER_POUND = 0.45359237;
private const double METERS_PER_INCH = 0.0254;
public static double CalculateBMI(double weightInPounds, double heightInInches)
{
double weightInKilos = weightInPounds * KILOGRAMS_PER_POUND;
double heightInMeters = heightInInches * METERS_PER_INCH;
double bmi = weightInKilos / (heightInMeters * heightInMeters);
return bmi;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment