5 ONERRORGOTO900
10 MODE8:DIM:ERASEa,a$:DIMa(2),a$(2):a$(0)="r:inside":a$(1)="R:outside":a$(2)="l:side"
20 s=0:n=3:ANGLE0:c$=CHR$(5):m$="Polygon (r,R,l) "
40 s$="A:area":z=s:GOSUB500:s=z
41 s$="n:number":z=n:GOSUB500:n=z:IFn<3 ORFRACn<>0 THEN41
45 CLS:PRINTm$;:PRINT
50 a(0)=SQR(s/n/TAN(180/n))
51 a(1)=SQR(2*s/n/SIN(360/n))
52 a(2)=SQR(ABS(4*s/n*TAN(180/n)))
100 FORi=0 TO2:PRINTc$;a$(i)" =";a(i);
110 w=ASC(INPUT$(1,@)):IFw=13 THEN170
120 IFw=30 ANDi>0 THENi=i-2:GOTO170
130 IFw=31 ANDi<2 THEN170
160 GOTO110
170 NEXT:GOTO40
500 CLS:PRINTm$;s$;
510 LOCATE0,1:PRINTc$;LEFT$(s$,1);"=";z;"?";:INPUT@42;z:LOCATE0,0:IFz<0 THEN510 ELSERETURN
900 IFERR=1 THENCLS:ONERRORGOTO0
910 IFERL=510 THENRESUME510
920 LOCATE0,1:PRINTc$;"not found";:z$=INPUT$(1,@):RESUME40