LoginSignup
0
0

More than 3 years have passed since last update.

GoでBMI計算機を作ってみた

Posted at

作成したもの

設計

BMIだけの計算するものはあったので、実際の使われ方に合わせて、年齢ごとに使用する体格指数を変えるようにしてみました

仕様に関して

今回は一般的になものを使いましたが、体格指数はいろいろな種類があるので、Interfaceを用意しています

type PonderalIndex interface {
    Calc(weight, height float64) (result float64, err error)
}

測定結果

// Result is a ponderal index calculation result
type Result struct {
    Classification string
    Index          float64
    IndexType      string
    Status         string
}

Classification (分類) / Status

Classification ステータス 分類
Severe thinness Fatal 痩せすぎ
Underweight Warning 痩せぎみ
Normal Normal 通常体重
Overweight Warning 太り気味
Obesity Fatal 肥満
Severe obesity Fatal 太り過ぎ

IndexType (インデックスの種類)

年齢 種類 参照
5歳未満 カウプ指数 https://www.benricho.org/bmi/02youji.html
5歳以上、15歳未満 ローレル指数 https://www.benricho.org/bmi/03jidou.html
15歳以上 BMI       https://www.wikiwand.com/en/Body_mass_index

使い方

インストール

git clone git@github.com/go-shway/shway.git
cd shway
go build -ldflags '-w -s' -o go-pi

基本的な使い方

# go-pi height(cm2) weight(kg) age 
e.g. go-pi 180 70 20
> Classification: Normal
> Index: 21.604938
> IndexType: Body Mass Index
> Status: Normal
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0