Im trying to write a program that will solve right triangles, depending on what side you need to find, to use in my statics class... its kinda nitty-gritty but seems to flow ok however when I execute the program I get back answers like " √(A²+B²)" instead of an actual numerical answer... Plz tell me what im doing wrong and where my lack of understanding lies in the layout of my program, here is the source code...

:Disp "0 FOR HYP","1 FOR LEG"
:Prompt X
:If X=0
:Goto θ
:If X=1
:Goto Z
:Lbl θ
:Prompt A,B
:Disp "√(A²+B²)
:Stop
Lbl Z
:Prompt C, D
:If C>D
:Then
:Disp "√(C²-D²)
:Else
:Disp "√(D²-C²)
:End
If you want a numerical answer, remove the quotes from the Disp command.

I removed the "If X=0" statement, because the program will always goto θ if X is not 1 anyways.

Code:
:Disp "0 FOR HYP","1 FOR LEG"
:Prompt X
:If X=1
:Goto Z
:Lbl θ
:Prompt A,B
:Disp √(A²+B²)
:Stop
:Lbl Z
:Prompt C, D
:If C>D
:Then
:Disp √(C²-D²)
:Else
:Disp √(D²-C²)
:End


Quotes specify a string (text) and the Disp command will output that text, up to 16 characters long before displaying "..." at the far right of the screen (which cannot be scrolled, and is a property of the Disp command). Without quotes, it will evaluate the expression and display the result.
ahgh!! Thank you so much Very Happy yea I realized that fact(removing the X=0) once I had sat around n thot for a bit Razz did not know about the quotes on Disp, thanks you guys rock!! Smile
Just to clarify exactly what that lesson is, using Disp, Output(, or Text( with a quoted "ENTITY" is a string, and will make the calculator display exactly what is in the quotes. Using them with something without quotes will make it try to evaluate the thing you've given it. Disp 3 is just 3, Disp 1+1 will display 2, Disp √(16) will display 4, and Disp HELLO WORLD will produce an error.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement