I've got a small code in TI BASIC on my TI-84 Plus C Silver Edition calculator that will determine correct dosage of drugs based on the patient's weight. For example, if aspirin is given at 5 mg per kg of patient weight (it isn't), then the code should tell me to give a 100kg patient 500mg of aspirin. However, the code is solving for every possible drug. Here it is:
PROGRAM:DRUG1
:Input "PATIENT WEIGHT: ",W
:Input "AGENT NAME: ",A
:If A=IPPI
:Disp "DOSAGE",W*2
:If A=NEVO
:Disp "DOSAGE", W*0.5
So in this case, the two drugs are IPPI
and NEVO
. If I give a patient weight of 100kg, and choose IPPI
, then I would expect to see
DOSAGE 200
However, what I do see is
DOSAGE 200
DOSAGE 50
so apparently both "if" statements are running, even though I've given a only one value (IPPI
). [The same error occurs when I set A
as NEVO
].
I've tried enclosing both If
statements within Then...End
as well, so the code would look like:
PROGRAM:DRUG1
:Input "PATIENT WEIGHT: ",W
:Input "AGENT NAME: ",A
:If A=IPPI
:Then
:Disp "DOSAGE",W*2
:End
:If A=NEVO
:Then
:Disp "DOSAGE", W*0.5
:End
but that changes nothing. I'm pretty new to BASIC, so I'm sure there's a simple error that I can't see, but I'm stumped at the moment.