## Friday, June 22, 2018

### HP Prime: Feet-Inches Calculator

HP Prime:  Feet-Inches Calculator

Calculate in Feet-Inches

The program FTIN is an arithmetic calculator that calculates in feet-inches and square feet.

At the start of the program, you will be asked to set an accuracy setting for fractions of inches.  The options available are 1/2, 1/4, 1/8, 1/16, 1/32, and 1/64.  You can change accuracy settings at any time.

Then you will be asked to enter a measurement either in feet-inches (linear) or square feet (area).   In feet-inches entry mode, you will enter the feet, whole inches, and fractional components of inches separately (see screen shot below).

When the main menu appears, your current result appears in the title screen of the choose box.

There are eight operations included in FTIN:

1. Add ft-in:  Adds a measurement in feet-inch to the displayed value
2. Subtract ft-in:  Subtracts a measurement in feet-inch from the displayed value
3. Multiply by scalar:  Multiplies measurement by a scalar.  Use this to find the total multiple of a feet-inch measurement.
4. Divide by scalar:  Works similarly to option 3.
5. Multiply to area:  Multiplies two lengths in feet-inch to obtain an area in square feet.
6. Divide from area:  Divides an area by a length in feet-inch
7. Square Root from area:  Takes the positive square root of a square area.  It’s good for a finding a length of a square given its area.
8. Change accuracy settings:  Change the accuracy settings for fraction of an inch.

Option 9 is to exit the program.

HP Prime Program FTIN

sub1();
sub2();

EXPORT FTIN()
BEGIN
// 2018-06-21 EWS

// initialization
LOCAL fx,fy,fz,ch;
LOCAL lx,ly,lz,Y,S;
LOCAL aflag,str,dh;

INPUT({{Y,
{2,4,8,16,32,64}}},
"ACCURACY DESIRED","/");
Y:=2^Y;

// initial entry
CHOOSE(dh,"Initial Units",
{"ft-in","ft^2"});
IF dh==1 THEN
fx:=sub1();
fz:=fx;
aflag:=0;
ELSE
INPUT(fx,"Enter Area","ft^2:");
fz:=fx;
aflag:=1;
END;

WHILE ch≠9 DO
fx:=fz;

// string for fz
IF aflag==0 THEN
lx:=sub2(fx,Y);
str:=STRING(lx(1))+" ft "+
STRING(lx(2))+" "+
STRING(lx(3))+" in";
ELSE
str:=STRING(fx)+" ft^2";
END;

CHOOSE(ch,str,
{"Add ft-in",
"Subtract ft-in",
"Multiply by scalar",
"Divide by scalar",
"Multiply to area",
"Divide from area",
"Square Root from area",
"Change accuracy settings",
"Quit"});

// add ft-in
IF ch==1 THEN
fy:=sub1();
fz:=fx+fy;
lx:=sub2(fx,Y);
ly:=sub2(fy,Y);
lz:=sub2(fz,Y);

PRINT();
PRINT(lx(1)+" ft "+lx(2)+
" "+lx(3)+" in");
PRINT("+");
PRINT(ly(1)+" ft "+ly(2)+
" "+ly(3)+" in");
PRINT("=");
PRINT(lz(1)+" ft "+lz(2)+
" "+lz(3)+" in");

WAIT(0);
END;

// subtract ft-in
IF ch==2 THEN
fy:=sub1();
fz:=fx-fy;
lx:=sub2(fx,Y);
ly:=sub2(fy,Y);
lz:=sub2(fz,Y);

PRINT();
PRINT(lx(1)+" ft "+lx(2)+
" "+lx(3)+" in");
PRINT("-");
PRINT(ly(1)+" ft "+ly(2)+
" "+ly(3)+" in");
PRINT("=");
PRINT(lz(1)+" ft "+lz(2)+
" "+lz(3)+" in");
WAIT(0);
END;

// multiply by scalar
IF ch==3 THEN
INPUT(S,"Enter Scalar");
fz:=fx*S;
lx:=sub2(fx,Y);
lz:=sub2(fz,Y);

PRINT();
PRINT(lx(1)+" ft "+lx(2)+
" "+lx(3)+" in");
PRINT("*");
PRINT(S);
PRINT("=");
PRINT(lz(1)+" ft "+lz(2)+
" "+lz(3)+" in");
WAIT(0);
END;

// divide by scalar
IF ch==4 THEN
INPUT(S,"Enter Scalar");
fz:=fx/S;
lx:=sub2(fx,Y);
lz:=sub2(fz,Y);

PRINT();
PRINT(lx(1)+" ft "+lx(2)+
" "+lx(3)+" in");
PRINT("/");
PRINT(S);
PRINT("=");
PRINT(lz(1)+" ft "+lz(2)+
" "+lz(3)+" in");
WAIT(0);
END;

// multiply to area
IF ch==5 THEN

fy:=sub1();
fz:=fx*fy;
fz:=ROUND(fz,6);
lx:=sub2(fx,Y);
ly:=sub2(fy,Y);
aflag:=1;

PRINT();
PRINT(lx(1)+" ft "+lx(2)+
" "+lx(3)+" in");
PRINT("*");
PRINT(ly(1)+" ft "+ly(2)+
" "+ly(3)+" in");
PRINT("=");
PRINT(fz+" ft^2");
WAIT(0);
END;

// divide from area
IF ch==6 THEN

fy:=sub1();
fz:=fx/fy;
ly:=sub2(fy,Y);
lz:=sub2(fz,Y);
aflag:=0;

PRINT();
PRINT(fx+" ft^2");
PRINT("/");
PRINT(ly(1)+" ft "+ly(2)+
" "+ly(3)+" in");
PRINT("=");
PRINT(lz(1)+" ft "+lz(2)+
" "+lz(3)+" in");
WAIT(0);
END;

// square root from area
IF ch==7 THEN
fz:=√(fx);
lz:=sub2(fz,Y);
aflag:=0;

PRINT();
PRINT("√"+fx+" ft^2");
PRINT("=");
PRINT(lz(1)+" ft "+lz(2)+
" "+lz(3)+" in");
WAIT(0);
END;

// change accruacy settings
IF ch==8 THEN
INPUT({{Y,
{2,4,8,16,32,64}}},
"ACCURACY DESIRED","/");
Y:=2^Y;
END;

END;

END;

// feet-inch-fraction entry
sub1()
BEGIN
LOCAL f,i,s,n;
INPUT({f,i,s,{n,
{2,4,8,16,32,64}}},
"ENTRY",
{"Feet: ","Inch: ",
"Frac: ","/"});
RETURN f+(i+s/(2^n))/12;
END;

// convert to feet-inch
sub2(x,y)
BEGIN
LOCAL f,i,s,t;
f:=IP(x);
i:=IP(FP(x)*12);
s:=ROUND(FP(FP(x)*12)*y,0);
t:=QPI(s/y);
RETURN {f,i,t};
END;

Eddie

All original content copyright, © 2011-2018.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.  Please contact the author if you have questions.

### Calculated Industries Qualifier Plus IIIFx: Logarithm, Exponential, Square Root

Calculated Industries Qualifier Plus IIIFx: Logarithm, Exponential, Square Root Introduction Say we have a financial calculator ...