How can I make a program that solves the area of a triangle. I know how to prompt the user, but I just don't know how to implement the equation into a program.
What info do you prompt? Which sides, angles...?
Base and height.
https://www.google.com/search?rlz=1CAHPZP_enUS810&ei=0cbhW9iLHIusswXk6KXQBg&q=triangle+area+formula&oq=triangle+area+formula&gs_l=psy-ab.3..0l10.49819.54531..54763...5.0..0.143.1984.25j1......0....1..gws-wiz.......0i71j0i67j0i10j0i22i30j0i22i10i30j0i13.wa5UuC6zm4U&safe=active&ssui=on
If it's only base and height you could do this:

:Prompt B
:Prompt H
:Disp "Area = "+eval(0.5*B*H
humanwormbaby wrote:
How can I make a program that solves the area of a triangle. I know how to prompt the user, but I just don't know how to implement the equation into a program.


The equation to find the area of a triangle is (1/2)*Base*Height

You could create 3 variables - one where you prompt for the base, another for the height, and the last one to store the answer to.

Example:

Code:

0->C
0->A
0->B
Disp "Height?
Prompt A
Disp "Base?
Prompt B
(.5*A*B)->C
Disp "Area:
Disp C
Stop


A=Height
B=Base
C=Area

Get it?
Thank you!
You could also do:

Code:

Input "HEIGHT?",A
Input "BASE?",B
Disp "AREA:",AB.5
  
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