欢迎来到天天文库
浏览记录
ID:56985271
大小:26.50 KB
页数:5页
时间:2020-07-30
《大型机cobol简易计算器.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、大型机cobol简易计算器000100IDDIVISION.000200PROGRAM-ID.COMPUT.000300ENVIRONMENTDIVISION.000400DATADIVISION.000410WORKING-STORAGESECTION.00050077FLAGPIC9.00060077OP-NUM1PIC9999.00070077OPS1PICX.00081077OP-NUM2PIC9999.00082077OPS2PICX.00083077OP-NUM3PIC9999.00101077STATESPIC9.001100P
2、ROCEDUREDIVISION.001200MAIN.001300PERFORMINIT-VALUES.001400PERFORMACCEPTIONUNTILSTATES=1.001500END-PROC.001510DISPLAYOP-NUM1.001520STOPRUN.001600ACCEPTION.001700IF(FLAG=1)001710THEN001800ACCEPTOP-NUM1001900MOVE2TOFLAG002000END-IF.002100IFFLAG=2002110THEN002200ACCEPTOPS10022
3、10IFOPS1='='002220GOTOEND-PROC002230END-IF002300MOVE3TOFLAG002400END-IF.002500IFFLAG=3002510THEN002600ACCEPTOP-NUM2002700MOVE4TOFLAG002800END-IF.002900IFFLAG=4002910THEN003000ACCEPTOPS2003100IFOPS2='='003110THEN003200PERFORMCOMP-LEFT003210MOVE1TOSTATES003300
4、GOTOEND-PROC003400END-IF003500IFOPS2='+'003510THEN003600PERFORMCOMP-LEFT003700END-IF003900IFOPS2='-'003910THEN004000PERFORMCOMP-LEFT004100END-IF004200COMPUTEFLAG=FLAG+1004210END-IF.004300IFFLAG=5004310THEN004400ACCEPTOP-NUM3004500PERFORMCOMP-RIGHT004600MOVE4
5、TOFLAG004700END-IF.004800COMP-LEFT.004900IFOPS1='+'004910THEN005000COMPUTEOP-NUM1=OP-NUM1+OP-NUM2005100END-IF.005200IFOPS1='-'005210THEN005300COMPUTEOP-NUM1=OP-NUM1-OP-NUM2005400END-IF.005500IFOPS1='*'005510THEN005600COMPUTEOP-NUM1=OP-NUM1*OP-NUM2005
6、700END-IF.005800IFOPS1='/'005810THEN005900IFOP-NUM2=0005901THEN005910DISPLAY'WRONGNUMBER2ACCEPTED!'006000GOTOEND-PROC-EXCEPTION006100END-IF006200COMPUTEOP-NUM1=OP-NUM1/OP-NUM2006300END-IF.006400MOVEOPS2TOOPS1.006500MOVE2TOFLAG006600COMP-RIGHT.006700IFOPS2=
7、39;*'006800COMPUTEOP-NUM2=OP-NUM2*OP-NUM3006900ELSE007000IFOPS2='/'007001THEN007010IFOP-NUM3=0007011THEN007012DISPLAY'WRONGNUMBER3ACCEPTED!'007020GOTOEND-PROC-EXCEPTION007030END-IF007100COMPUTEOP-NUM2=OP-NUM2/OP-NUM3007200ELSE007300DISPLAY'WRONGOPERA
8、TOR(2)ACCEPTED!'007400GOTOEND-PROC-EXCEPTION007500END-IF007600END-IF.007700MOV
此文档下载收益归作者所有