IDENTIFICATION DIVISION. PROGRAM-ID. CCTRNR. * Card Counting Trainer ELG 29-NOV-89 ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 WAIT-TIME USAGE COMP-1 VALUE 1. 01 NUM-CARDS PIC 99 COMP. 01 COUNTERS. 05 INPUT-COUNT PIC S9(4) COMP. 05 WORK-CNT PIC S9(4) COMP. 01 RANDOM-NUMBER-STORAGE. 05 RANDOM-SEED PIC S9(9) COMP. 05 RANDOM-RETURN USAGE COMP-1. 05 RANDOM-VALUE PIC 99. 05 SYSTEM-TIME. 10 ST-HOURS PIC 99. 10 ST-MINUTES PIC 99. 10 ST-SECONDS PIC 99. 10 ST-HUNDREDTHS PIC 99. 05 CARD-VALUE PIC 99. 01 CARD. 05 CARD-DISP. 10 CARD-NDISP PIC Z9. 05 FILLER PIC X VALUE SPACES. 01 R-IDX PIC 99 COMP. 01 REVIEW-STRING. 05 RCARD PIC X(3) OCCURS 20. PROCEDURE DIVISION. MAIN-PROGRAM SECTION. BEGIN-RUN. DISPLAY "Card Counting Trainer" LINE 1 ERASE SCREEN. DISPLAY "Enter 0 to end program" COLUMN 55. ACCEPT SYSTEM-TIME FROM TIME. COMPUTE RANDOM-SEED = (ST-MINUTES + 1) * (ST-SECONDS + 1) * (ST-HUNDREDTHS + 1) * 4521. * LOOP. DISPLAY "Number of cards to deal:<5> " LINE 3 ERASE LINE. ACCEPT NUM-CARDS WITH CONVERSION COLUMN PLUS DEFAULT "5" AT END GO TO END-OF-JOB. IF NUM-CARDS < 1 GO TO END-OF-JOB. IF NUM-CARDS > 20 GO TO LOOP. DISPLAY LOW-VALUES LINE 6. MOVE 0 TO WORK-CNT R-IDX. MOVE SPACES TO REVIEW-STRING. LOOP2. PERFORM DEAL-CARD. SUBTRACT 1 FROM NUM-CARDS. IF NUM-CARDS > 0 GO TO LOOP2. DISPLAY LOW-VALUES. * DISPLAY LOW-VALUES LINE 6 ERASE END SCREEN. DISPLAY "What is the count?" LINE 8. ACCEPT INPUT-COUNT WITH CONVERSION COLUMN PLUS AT END GO TO END-OF-JOB. DISPLAY LOW-VALUES LINE 10. IF INPUT-COUNT = WORK-CNT DISPLAY "You are correct." ELSE DISPLAY "WRONG, pilgrim.". DISPLAY "The correct answer is " WORK-CNT WITH CONVERSION. DISPLAY "The cards were:" LINE 12. DISPLAY REVIEW-STRING LINE 13. GO TO LOOP. END-OF-JOB. DISPLAY LOW-VALUES LINE 15. STOP RUN. * DEAL-CARD. CALL "MTH$RANDOM" USING RANDOM-SEED GIVING RANDOM-RETURN. COMPUTE RANDOM-VALUE ROUNDED = RANDOM-RETURN * 12 + 1. MOVE RANDOM-VALUE TO CARD-VALUE. MOVE CARD-VALUE TO CARD-NDISP. IF CARD-VALUE = 1 MOVE " A" TO CARD-DISP ELSE IF CARD-VALUE > 10 MOVE 10 TO CARD-VALUE IF RANDOM-VALUE = 11 MOVE " J" TO CARD-DISP ELSE IF RANDOM-VALUE = 12 MOVE " Q" TO CARD-DISP ELSE MOVE " K" TO CARD-DISP. IF CARD-VALUE = 1 SUBTRACT 2 FROM WORK-CNT ELSE IF CARD-VALUE > 8 SUBTRACT 1 FROM WORK-CNT ELSE IF CARD-VALUE = 5 ADD 2 TO WORK-CNT ELSE IF CARD-VALUE < 8 ADD 1 TO WORK-CNT. DISPLAY CARD WITH NO ADVANCING. ADD 1 TO R-IDX. MOVE CARD TO RCARD(R-IDX). CALL "LIB$WAIT" USING WAIT-TIME.