Voici un simple programme qui calcule l'IMC, et vous affiche votre poids idéal:
Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Calcul IMC - Indice de Masse Corporelle", 500, 420, (@DesktopWidth-500)/2, (@DesktopHeight-420)/2)
GUISetBkColor("0xFFCC00")
$Label1 = GUICtrlCreateLabel("Masse (en kg):", 10, 10)
$Input1 = GUICtrlCreateInput("", 10, 30, 480, 20)
$Label1 = GUICtrlCreateLabel("Taille (en cm):", 10, 60)
$Input2 = GUICtrlCreateInput("", 10, 80, 480, 20)
$Button1 = GUICtrlCreateButton("IMC", (500-100)/2, 120, 100, 50)
$Label3 = GUICtrlCreateLabel("", 10, 190, 480, 100)
GUICtrlSetColor(-1, "0xFF3300")
GUICtrlSetBkColor(-1, "0xFF9900")
GUICtrlSetFont(-1, 32)
$Label4 = GUICtrlCreateLabel("Votre poids idéal serait: ", 10, 320, 480, 100)
GUICtrlSetColor(-1, "0xFF6600")
GUICtrlSetFont(-1, 32)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_Event_Close
Exit
Case $Button1
$Masse = GUICtrlRead($Input1)
$Taille = GUICtrlRead($Input2)/100
$IMC = Round($Masse/($Taille*$Taille), 1)
If $Masse = "" Then $Interpretation = ""
If $Taille = "" Then $Interpretation = ""
If $IMC < 16.5 Then $Interpretation = "Dénutrition ou famine."
If $IMC > 16.5 AND $IMC < 18.5 Then $Interpretation = "Maigreur."
If $IMC > 18.5 AND $IMC < 25 Then $Interpretation = "Corpulence normale."
If $IMC > 25 AND $IMC < 30 Then $Interpretation = "Surpoids."
If $IMC > 30 AND $IMC < 35 Then $Interpretation = "Obésité modérée."
If $IMC > 35 AND $IMC < 40 Then $Interpretation = "Obésité sévère."
If $IMC > 40 Then $Interpretation = "Obésité morbide ou massive."
GUICtrlSetData($Label3, "" & $Interpretation)
$Interpretation = ""
$Min = 0
Do
$Min = $Min+1
$IMC = Round($Min/($Taille*$Taille), 1)
Until($IMC > 18.5 AND $IMC < 25)
$Max = $Min
Do
$Max = $Max+1
$IMC = Round($Max/($Taille*$Taille), 1)
Until($IMC > 25 AND $IMC < 30)
$PoidsIdeal = ($Min+$Max)/2
GUICtrlSetData($Label4, "Votre poids idéal serait: " & $PoidsIdeal & " kg.")
EndSwitch
WEnd