ti basic - Trouble on "If" statement on TI-84 Plus C Silver Edition -


i've got small code in ti basic on ti-84 plus c silver edition calculator determine correct dosage of drugs based on patient's weight. example, if aspirin given @ 5 mg per kg of patient weight (it isn't), code should tell me give 100kg patient 500mg of aspirin. however, code solving every possible drug. here 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 case, 2 drugs ippi , nevo. if give patient weight of 100kg, , choose ippi, expect see

dosage                 200 

however, see is

dosage              200 dosage               50 

so apparently both "if" statements running, though i've given 1 value (ippi). [the same error occurs when set a nevo].

i've tried enclosing both if statements within then...end well, code 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 changes nothing. i'm pretty new basic, i'm sure there's simple error can't see, i'm stumped @ moment.

you need change second input command information stored string instead of numeric variable a. ti-84 series calculators have ten string variables in [vars][7] menu purpose.

note must compare string against string "ippi" rather sequence of letters (numeric variables) ippi. code be:

:input "patient weight: ",w :input "agent name: ",str1 :if str1="ippi" :disp "dosage: ",w*2 :if str1="nevo" :disp "dosage: ",w*0.5 

or more concisely:

:input "patient weight: ",w :input "agent name: ",str1 :disp "dosage:" :if str1="ippi" :disp 2w :if str1="nevo" :disp .5w 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -