(41C) Area of Triangle (SSS)
11-11-2018, 04:25 PM (This post was last modified: 11-11-2018 06:08 PM by Dieter.)
Post: #7
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: (41C) Area of Triangle (SSS)
(11-11-2018 12:23 PM)Gamo Wrote:  I have test by deleted the LBL 02 and changed GTO 02 to GTO 03 so it work ok now.

It works exactly the same as before, just with less steps. ;-)

But what about the input order now? How do A, B and C have to be entered so that the program always returns correct results? For right-angled triangles C must be the largest side, while on the other hand for the isosceles example C is the smallest side. ?!?

You should assume that the user does not know which kind of triangle enters. After all, that's what the program is supposed to display. So the only rule can be something like "enter sides in ascending order" (or similar). But this requires a modification of the program.

Edit: here is a possible solution. Enter the three sides in ascending order, i.e. A≤B≤C.

I tried to preserve as much of your original program as possible. The output routine has been changed, you may modify it according to your likings. The program now ends in one common endpoint for all cases at LBL 00 so that you can restart it with a simple [R/S].

Code:
LBL "SSS" "A=?" PROMPT STO 01 "B=?" PROMPT STO 02 "C=?" PROMPT STO 03 RCL 02 + RCL 01 + 2 ÷ STO 04 RCL 04 RCL 01 - RCL 04 RCL 02 - x RCL 04 RCL 03 - x x √x STO 04 RCL 01 X^2 RCL 02 X^2 + RCL 03 X^2 X=Y? GTO 01 RCL 01 RCL 02 X=Y? GTO 02 RCL 02 RCL 03 X=Y? GTO 03 "SCALENE" GTO 00 -------------------------- LBL 01 "RIGHT ANGLED" GTO 00 -------------------------- LBL 02 RCL 02 RCL 03 X=Y? GTO 04 -------------------------- LBL 03 "ISOSCELES" GTO 00 ------------------------- LBL 04 "EQUILATERAL" -------------------------- LBL 00 AVIEW PSE RCL 04 "AREA=" ARCL 04 AVIEW END

Dieter
 « Next Oldest | Next Newest »

 Messages In This Thread (41C) Area of Triangle (SSS) - Gamo - 11-10-2018, 12:20 PM RE: (41C) Area of Triangle (SSS) - Albert Chan - 11-10-2018, 03:22 PM RE: (41C) Area of Triangle (SSS) - Dieter - 11-10-2018, 08:53 PM RE: (41C) Area of Triangle (SSS) - Albert Chan - 11-12-2018, 02:55 PM RE: (41C) Area of Triangle (SSS) - Dieter - 11-12-2018, 08:28 PM RE: (41C) Area of Triangle (SSS) - Albert Chan - 11-12-2018, 10:33 PM RE: (41C) Area of Triangle (SSS) - Gamo - 11-11-2018, 05:04 AM RE: (41C) Area of Triangle (SSS) - Dieter - 11-11-2018, 07:53 AM RE: (41C) Area of Triangle (SSS) - Gamo - 11-11-2018, 12:23 PM RE: (41C) Area of Triangle (SSS) - Dieter - 11-11-2018 04:25 PM RE: (41C) Area of Triangle (SSS) - Albert Chan - 11-12-2018, 01:32 AM RE: (41C) Area of Triangle (SSS) - Albert Chan - 11-16-2018, 03:33 AM RE: (41C) Area of Triangle (SSS) - Albert Chan - 12-04-2019, 03:03 PM

User(s) browsing this thread: 1 Guest(s)