10 CLS
20 KEY OFF
30 PRINT "ACCRUED INTEREST ON BONDS"
40 PRINT
50 PRINT "COMPUTE USING:"
60 PRINT "              1) 360 DAY YEAR"
70 PRINT "              2) 365/366 DAY YEAR"
80 PRINT "              3) END PROGRAM"
90 PRINT "       WHICH";
100 INPUT T
110 ON T GOTO 130,130,1050
120 GOTO 90
130 PRINT
140 PRINT "           COUPON RATE (%)";
150 INPUT I
160 PRINT "NUMBER OF COUPONS PER YEAR";
170 INPUT N
180 X1=0
190 PRINT "DOES THIS COUPON INCLUDE A";
200 PRINT " LONG FIRST YEAR PERIOD (Y/N)";
210 INPUT Z$
220 IF Z$="N" OR Z$="n" THEN 520
230 IF Z$<>"Y" AND Z$<>"y" THEN 190
240 REM  -- SKIP THIS SECTION IF FIRST PERIOD IS NOT LONG
250 PRINT
260 PRINT "  BEGINNING OF FIRST PERIOD";
270 GOSUB 880
280 X2=A4
290 REM  -- ISSUE DATE IS DATE CURRENT BONDHOLDER OBTAINED THE BOND
300 PRINT "                 ISSUE DATE";
310 GOSUB 880
320 REM  -- X1 = NUMBER OF DAYS FROM ISSUE TO END OF PARTIAL PERIOD
330 X1=A4-X2
340 IF X1>0 THEN 380
350 PRINT
360 PRINT "A LONG FIRST PERIOD MUST BEGIN BEFORE ISSUE."
370 GOTO 810
380 PRINT "          FIRST COUPON DATE";
390 GOSUB 880
400 REM  -- X2 = TOTAL NUMBER OF DAYS IN FIRST PERIOD
410 X2=A4-X2
420 IF X2>0 THEN 460
430 PRINT
440 PRINT "A LONG FIRST PERIOD MUST BEGIN BEFORE FIRST COUPON DATE."
450 GOTO 810
460 IF X2-X1>0 THEN 500
470 PRINT
480 PRINT "FIRST COUPON DATE MAY NOT OCCUR BEFORE ISSUE."
490 GOTO 810
500 X1=(X2-X1)/X2
510 GOTO 570
520 PRINT
530 PRINT "BEGINNING OF CURRENT PERIOD";
540 GOSUB 880
550 REM  -- X3 = ABSOLUTE NUMBER OF DAYS FROM IMAGINARY DATE
560 REM  --      00/00/00 TO BEGINNING OF CURRENT PERIOD
570 X3=A4
580 PRINT "      END OF CURRENT PERIOD";
590 GOSUB 880
600 REM  -- X4 = TOTAL NUMBER OF DAYS IN CURRENT PERIOD
610 X4=A4-X3
620 IF X4>=0 THEN 690
630 PRINT
640 IF X$="Y" OR Z$="y" THEN 670
650 PRINT "CURRENT PERIOD MAY NOT END BEFORE IT BEGINS."
660 GOTO 810
670 PRINT "CURRENT PERIOD MAY NOT END BEFORE ISSUE OR FIRST COUPON DATE"
680 GOTO 810
690 PRINT "            SETTLEMENT DATE";
700 GOSUB 880
710 REM  -- X3 = NUMBER OF DAYS FROM BEGINNING OF
720 REM  --      CURRENT PERIOD TO SETTLEMENT DATE
730 X3=A4-X3
740 IF X3>=0 THEN 780
750 PRINT
760 PRINT "SETTLEMENT MAY NOT OCCUR BEFORE ISSUE OR FIRST COUPON DATE"
770 GOTO 810
780 X3=(X3/X4)+X1
790 PRINT
800 PRINT "ACCRUED INTEREST IS";I/N*X3;"% OF PAR."
810 PRINT
820 PRINT "WOULD YOU LIKE TO RE-RUN PROGRM";
830 PRINT " USING NEW DATA (Y/N)?"
840 Z$=INKEY$:IF Z$="" THEN 840
850 IF Z$="Y" OR Z$="y" THEN 40
860 IF Z$="N" OR Z$="n" THEN 1050
870 GOTO 820
880 INPUT " (MM,DD,YY)"; M,D,Y
890 IF T=1 THEN 1030
900 REM  -- SUBROUTINE TO DETERMINE NUMBER OF DAYS BETWEEN IMAGINARY
910 REM  -- DATE 00/00/00 AND MM/DD/YY USING 365/366 DAY YEAR.
920 REM  -- REF. ACCOUNTS PAYABLE & ACCOUNTS RECEIVABLE (WANG), P.255
930 RESTORE
940 DATA 0,3,3,6,8,11,13,16,19,21,24,26
950 FOR I1=1 TO M
960 READ A4
970 NEXT I1
980 A4=A4+Y*365+INT(Y/4)+1+(M-1)*28+D
990 IF INT(Y/4)=Y/4 AND M<3 THEN A4=A4-1
1000 RETURN
1010 REM  -- SUBROUTINE TO COMPUTE NUMBER OF DAYS FROM
1020 REM  -- IMAGINARY DATE 00/00/00 TO MM/DD/YY USING 360 YEAR.
1030 A4=(Y*360)+(M*30)+D
1040 RETURN
1050 END