My watch battery in my TI-85 died and I cannot find my old printout of my program.

I HAD a program that would calculate latitude and departure of surveying legs and calculate a closure error for me.

the basic math is pretty simple, and I rebuilt that part.

What I am having trouble with is the if/then statement to determine the base direction: NE, SE, SW, NW of the bearings.

Latitude = Length*cos a

Departue=Length*sin a

I use the variable Q (Quadrant) with values 1-4 (1=NE, etc)

This will set the variable to either add or subtract the latitude and departure from the coordinates of the previous points.

Where I am right now and cannot get it to work. I wrote the program back in the 90s and had it on a floppy for a while (plus a printout)

(just the logic part, everything else works)

```
IF Q=1
THEN
W=1
X=1
IF Q=2
THEN
W=1
X=-1
IF Q=3
THEN
W=-1
X=-1
IF Q=2
THEN
W=-1
X=1
END
DISP W
DISP X
```

The program crashes every time. I've tried to add an ELSE command, but that didn't solve it either.

Help, please!

Thanks!!