Friday, June 23, 2017

HP Prime and Casio fx-CG50: Trapezoid Midsegment, Height, Area

HP Prime and Casio fx-CG50:  Trapezoid Midsegment, Height, Area



The program TRAPEZ calculates the following:

Midsegment length:  M = (A + B)/2

Height:  H = √( (-A+B+C+D)(A-B+C+D)(A-B+C-D)(A-B-C+D) )/(2 * abs(B-A))

Area:  K = M * H

HP Prime Program TRAPEZ

EXPORT TRAPEZ()
BEGIN
// trapezoid
// 2017-06-23 EWS

INPUT({A,B,C,D},
"Trapezoid",
{"a: ","b: ","c: ","d: "},
{"Top","Bottom","Left","Right"});

M:=(A+B)/2;
I:=(−A+B+C+D)*(A-B+C+D)*(A-B+C-D)*
(A-B-C+D);
IF I≤0 THEN
PRINT();
PRINT("Invalid Trapezoid");
ELSE
H:=√(I)/(2*ABS(B-A));
K:=H*M;
PRINT();
PRINT("Midlength = "+M);
PRINT("Height = "+H);
PRINT("Area = "+K);
END;

END;

Casio fx-CG50 Program TRAPEZ

"TOP"?->A
"BOTTOM"?->B
"LEFT"?->C
"BOTTOM"?->D
(A+B)/2->M
((-)A+B+C+D)(A-B+C+D)(A-B+C-D)(A-B-C+D)->I
If I<=0
Then
"INVALID TRAPEZIOD"DispsElse
√I/(2Abs (B-A))->H
M*H->K
ClrText
Locate 1,1,"MIDLENGTH="
Locate 1,2,M
Locate 1,3,"HEIGHT="
Locate 1,4,H
Locate 1,5,"AREA="
Locate 1,6,K
IfEnd

Example

A = 13, B = 23, C = 6, D = 7
Results:
Midlength, M = 18
Height, H = 4.139493194
Area, A = 74.3848775

Source:
“Trapezoid”  Wikipedia.  Edited July 7, 2014.  Retrieved July 8, 2014

Eddie


This blog is property of Edward Shore, 2017.