10 PRINT "COORDINATE CONVERSION"
20 PRINT 
30 PRINT "                ( 1=CARTESIAN TO POLAR)"
40 PRINT "                (-1=POLAR TO CARTESIAN)"
50 PRINT "                ( 0=END PROGRAM)"
60 PRINT "WHICH DIRECTION";
70 INPUT D
79 REM - END PROGRAM?
80 IF D=0 THEN 380
89 REM - DIRECT PROGRAM TO PERFORM PROPER CONVERSION
90 IF D=-1 THEN 320
98 REM - CONVERT FROM CARTESIAN COORDINATES TO POLAR COORDINATES
99 REM - ENTER CARTESIAN COORDINATES (ABSCISSA, ORDINATE)
100 PRINT "X,Y";
110 INPUT X,Y
119 REM - POINT ON Y-AXIS?
120 IF X=0 THEN 170
129 REM - POINT ON X-AXIS?
130 IF Y=0 THEN 260
139 REM - COMPUTE POLAR COORDINATES, ROUND OFF, PRINT
140 PRINT "R =";INT(SGN(X)*SQR(X[2+Y[2)*100+.5)/100;",";
150 PRINT " A =";INT(ATN(Y/X)*180/3.1415927*100+.5)/100
160 GOTO 60
169 REM - POINT IS ON Y-AXIS; AT ORIGIN?
170 IF Y=0 THEN 240
180 PRINT "R =";ABS(Y);",";
189 REM - IS POINT ABOVE OR BELOW ORIGIN?
190 IF Y<0 THEN 220
200 PRINT " A = 90"
210 GOTO 60
220 PRINT " A = 270"
230 GOTO 60
239 REM - POINT IS AT ORIGIN
240 PRINT "R = 0,  A = 0"
250 GOTO 60 
259 REM - POINT IS ON X-AXIS
260 PRINT "R =";ABS(X);",";
269 REM - IS POINT TO LEFT OR RIGHT OF ORIGIN?
270 IF X<0 THEN 300
280 PRINT "  A = 0"
290 GOTO 60
300 PRINT "  A = 180"
310 GOTO 60
318 REM - CONVERT FROM POLAR COORDIATES TO CARTESIAN COORDINATES
319 REM - ENTER POLAR COORDINATES (MAGNITUDE OF RAY, ANGLE)
320 PRINT "R,A";
330 INPUT R,A
339 REM - CONVERT FROM DEGREES TO RADIANS
340 M=(A-INT(A/360)*360)*3.1415927/180
349 REM - CALCULATE CARTESIAN COORDINATES, ROUND OFF, PRINT
350 PRINT "X =";INT(R*COS(M)*100+.5)/100;",";
360 PRINT "  Y =";INT(R*SIN(M)*100+.5)/100
370 GOTO 60
380 END
