< Programmeren in TI-Basic

Op deze pagina staat het programma BMI-calculator, een simpel programmaatje, vooral handig om te oefenen met het programmeren in TI-basic. Eerst het programma, daarna de uitleg. Voor meer informatie over BMI, kijk op de pagina over BMI op wikipedia. (zie link onderaan pagina)

Bijschriften bij je 'BMIscore' gelden alleen voor mensen in de leeftijd 18-65 jaar!

Het programma

:Clrhome
:Disp "------BMI------","
:Output(3,15,"KG
:Input "GEWICHT: ",G
:Output(3,15,"                   ← Let op! Twee spaties!
:Output(4,16,"M
:Input "LENGTE:  ",L
:Output(4,16,"                   ← Let op! Één spatie!
:G/L²→B
:Disp "","BMI:
:Output(6,6,round(B,2
:If B≤18.5
:Disp "TE LICHT
:If B>18.5 and B≤25
:Disp "GEZOND GEWICHT
:If B>25 and B≤27
:Disp "BEETJE TE ZWAAR
:If B>27 and B≤30
:Disp "TE ZWAAR
:If B>30 and B≤40
:Disp "VEEL TE ZWAAR
:If B>40
:Disp "ZIEKELIJK ZWAAR
:Pause
:ClrHome

Uitleg

:Clrhome
:Disp "------BMI------","
:Output(3,15,"KG
:Input "GEWICHT: ",G
:Output(3,15,"                   ← Let op! Twee spaties!
:Output(4,16,"M
:Input "LENGTE:  ",L
:Output(4,16,"                   ← Let op! Één spatie!

In dit stukje wordt het scherm geleegd, wordt ------BMI------ bovenaan geschreven en worden gewicht en lengte gevraagd. Bij gewicht wordt er kg achteraan de regel gezet, en nadat het gewicht is ingevult wordt dit weer 'weggegumd' met twee spaties. Bij lengte wordt het zelfde uitgevoerd, dan met m.

:G/L²→B
:Disp "","BMI:
:Output(6,6,round(B,2

Hier komt de verwerking. Eerst word de BMI berekend, daarna wordt deze getoond met Disp en Output(. Met het commando round( wordt het BMI-getal afgerond op twee achter de komma.

:If B≤18.5
:Disp "TE LICHT
:If B>18.5 and B≤25
:Disp "GEZOND GEWICHT
:If B>25 and B≤27
:Disp "BEETJE TE ZWAAR
:If B>27 and B≤30
:Disp "TE ZWAAR
:If B>30 and B≤40
:Disp "VEEL TE ZWAAR
:If B>40
:Disp "ZIEKELIJK ZWAAR
:Pause
:ClrHome

In dit stukje wordt telkens de 'BMIscore' vergeleken met BMI categorieën, om vervolgens bij de juiste categorie het juiste bijschrift geplaatst.

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.