mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-08 20:54:38 +02:00
1.5 KiB
1.5 KiB
Script: calculate-BMI.ps1
This PowerShell script calculates the BMI.
Parameters
PS> ./calculate-BMI.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
Example
PS> ./calculate-BMI.ps1
Notes
Author: Markus Fleschutz | License: CC0
Related Links
https://github.com/fleschutz/PowerShell
Script Content
<#
.SYNOPSIS
Calculate the BMI
.DESCRIPTION
This PowerShell script calculates the BMI.
.EXAMPLE
PS> ./calculate-BMI.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
#requires -version 5.1
try {
[float]$height = Read-Host("Enter your height in m ")
[float]$weight = Read-Host("Enter your weight in kg")
$BMI = $weight / ($height * $height)
"Your BMI is $BMI, for adults the WHO regards <16 as Underweight (severe thinness), 16-17 as Underweight (moderate thinness), 17-18.5 as Underweight (mild thinness), 18.5-25 as Normal range, 25-30 as Overweight (pre-obese), 30-35 as Obese (class I), 35-40 as Obese (class II), and >=40 as Obese (class III)."
exit 0 # success
} catch {
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
exit 1
}
(page generated by convert-ps2md.ps1 as of 08/07/2025 16:01:02)