Files
PowerShell/docs/calculate-BMI.md
Markus Fleschutz 7ee6a194c4 Updated the manuals
2025-08-07 16:01:32 +02:00

62 lines
1.5 KiB
Markdown

Script: *calculate-BMI.ps1*
========================
This PowerShell script calculates the BMI.
Parameters
----------
```powershell
PS> ./calculate-BMI.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
```
Example
-------
```powershell
PS> ./calculate-BMI.ps1
```
Notes
-----
Author: Markus Fleschutz | License: CC0
Related Links
-------------
https://github.com/fleschutz/PowerShell
Script Content
--------------
```powershell
<#
.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)*