Skip to content

Instantly share code, notes, and snippets.

@jhinrichsen
Created April 12, 2018 11:48
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 jhinrichsen/2ea32fecca9055db0295a5217fd02a20 to your computer and use it in GitHub Desktop.
Save jhinrichsen/2ea32fecca9055db0295a5217fd02a20 to your computer and use it in GitHub Desktop.
BMI commandline calculator
package main
import (
"fmt"
"os"
"strconv"
)
func Bmi(m, l float64) int {
return int(m/(l*l) + 0.5)
}
func main() {
m, err := strconv.ParseFloat(os.Args[1], 64)
if err != nil {
panic(err)
}
l, err := strconv.ParseFloat(os.Args[2], 64)
if err != nil {
panic(err)
}
fmt.Println(Bmi(m, l))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment