000100 ID DIVISION. 00010000 000200 PROGRAM-ID. TRPGM72. 00020000 000300*AUTHOR. Kenneth W. Caldwell. 00030000 000400*INSTALLATION. Train-Right. 00040000 000500*DATE-WRITTEN. December 6, 2010. 00050000 000600*DATE-COMPILED. 00060000 000700* 00070000 000800*SECURITY. This program is for students of Train-Right 00080000 000900* courses ONLY!. 00090000 001000* 00100000 001100*REMARKS. This program plays Rock, Paper, Scissors. 00110000 001200* It is a Conversational program. 00120000 001300* 00130000 001400 DATA DIVISION. 00140000 001500 WORKING-STORAGE SECTION. 00150000 001600 01. 00160000 001700 05 wins PIC S9(4) BINARY VALUE ZERO. 00170000 001800 05 losses PIC S9(4) BINARY VALUE ZERO. 00180000 001900 05 pgm-choice PIC 9 PACKED-DECIMAL. 00190000 002000 05 result. 00200000 002100 10. 00210000 002200 15 user-input-first. 00220000 002300 20 PIC X(5) VALUE SPACES. 00230000 002400 20 user-input PIC X(8) VALUE SPACES. 00240000 002500 15 user-choice REDEFINES user-input-first 00250000 002600* PIC X(13). 00260000 002700 PIC X(8). 00270000 002800 15 PIC X(67) VALUE SPACES. 00280000 002900 10 msg1 PIC X(80). 00290000 003000 10 msg2 PIC X(80) VALUE 00300000 003100 'Change your choice and press ENTER to play again. Ent00310000 003200- 'er EXIT to stop playing.'. 00320000 003300 10 msg3. 00330000 003400 15 PIC X(6) VALUE 'Wins: '. 00340000 003500 15 msg3-wins PIC ZZ,ZZ9. 00350000 003600 15 PIC X(2) VALUE '. '. 00360000 003700 15 PIC X(8) VALUE 'Losses: '. 00370000 003800 15 msg3-losses PIC ZZ,ZZ9. 00380000 003900 15 PIC X(2) VALUE '. '. 00390000 004000 00400000 004100 PROCEDURE DIVISION. 00410000 004200 Main. 00420000 004300 COMPUTE pgm-choice ROUNDED = 00430000 004400 FUNCTION RANDOM(eibtaskn + eibtime) * 2 00440000 004500 END-COMPUTE. 00450000 004600 00460000 004700 Receive-Trans-Input. 00470000 004800 EXEC CICS IGNORE CONDITION LENGERR END-EXEC. 00480000 004900 EXEC CICS RECEIVE INTO(user-input-first) 00490000 005000 MAXFLENGTH(LENGTH OF user-input-first) 00500000 005100 END-EXEC. 00510000 005200 00520000 005300 MOVE user-input TO user-input-first. 00530000 005400 00540000 005500 Process-Data-Loop. 00550000 005600 EVALUATE user-choice ALSO pgm-choice 00560000 005700 WHEN 'EXIT' ALSO ANY 00570000 005800 GO TO Process-Exit 00580000 005900 WHEN 'ROCK' ALSO 0 00590000 006000 MOVE 'Two Rocks is a tie.' TO msg1 00600000 006100 WHEN 'PAPER' ALSO 1 00610000 006200 MOVE 'Two Papers is a tie.' TO msg1 00620000 006300 WHEN 'SCISSORS' ALSO 2 00630000 006400 MOVE 'Two Scissors is a tie.' TO msg1 00640000 006500 WHEN 'ROCK' ALSO 1 00650000 006600 MOVE 'Paper covers Rock - I win!' TO msg1 00660000 006700 ADD +1 TO losses 00670000 006800 WHEN 'ROCK' ALSO 2 00680000 006900 MOVE 'Rock smashes Scissors - You win!' TO msg1 00690000 007000 ADD +1 TO wins 00700000 007100 WHEN 'PAPER' ALSO 0 00710000 007200 MOVE 'Paper covers Rock - You win!' TO msg1 00720000 007300 ADD +1 TO wins 00730000 007400 WHEN 'PAPER' ALSO 2 00740000 007500 MOVE 'Scissors cut Paper - I win!' TO msg1 00750000 007600 ADD +1 TO losses 00760000 007700 WHEN 'SCISSORS' ALSO 0 00770000 007800 MOVE 'Rock smashes Scissors - I win!' TO msg1 00780000 007900 ADD +1 TO losses 00790000 008000 WHEN 'SCISSORS' ALSO 1 00800000 008100 MOVE 'Scissors cut Paper - You win!' TO msg1 00810000 008200 ADD +1 TO wins 00820000 008300 WHEN OTHER 00830000 008400 MOVE 'You did not select "Rock", "Paper", or "Scissors". Pl00840000 008500- 'ease try again.' TO msg1 00850000 008600 END-EVALUATE. 00860000 008700 00870000 008800 MOVE wins TO msg3-wins. 00880000 008900 MOVE losses TO msg3-losses. 00890000 009000 00900000 009100 Send-Result. 00910000 009200 EXEC CICS SEND FROM(result) ERASE END-EXEC. 00920000 009300 00930000 009400 Wait-For-Response. 00940000 009500 EXEC CICS RECEIVE INTO(user-choice) 00950000 009600 MAXFLENGTH(LENGTH OF user-choice) 00960000 009700 END-EXEC. 00970000 009800 00980000 009900 COMPUTE pgm-choice ROUNDED = FUNCTION RANDOM * 2 END-COMPUTE.00990000 010000 01000000 010100 GO TO Process-Data-Loop. 01010000 010200 01020000 010300 Process-Exit. 01030000 010400 EXEC CICS SEND CONTROL ERASE END-EXEC. 01040000 010500 EXEC CICS RETURN END-EXEC. 01050000 010600* Dummy GOBACK. 01060000 010700 GOBACK. 01070000