需要有关语法错误的帮助(COBOL)

时间:2010-12-08 21:29:18

标签: syntax-error cobol

我正在为本学期的COBOL做最后的作业,我遇到的语法错误正在阻止我的进展。这是我得到的:

   ENVIRONMENT DIVISION.
   INPUT-OUTPUT SECTION.
   FILE-CONTROL.

       SELECT USED-CAR-FILE-OUT
           ASSIGN TO 'USED-CAR.RPT'
           ORGANIZATION IS LINE SEQUENTIAL.

   DATA DIVISION.
   FILE SECTION.

   FD  USED-CAR-FILE-OUT.
   01  USED-CAR-RECORD-OUT         PIC X(80).

   WORKING-STORAGE SECTION.
   01  ID-CODE                     PIC X(3).
   01  TOTAL-CASH-PAYMENT          PIC 9(5).
   01  MONTHLY-PAYMENT             PIC 9(4).
   01  NUMBER-OF-MONTHS            PIC 9(3).

   01  BALANCE-TOTAL               PIC S9(6)V99 VALUE ZEROS.

   01  INTEREST-EARNED             PIC S99V99   VALUE ZEROS.

   01  COMPARE-MONTH               PIC 99       VALUE ZEROS.

   01  YEAR-NUMBER                 PIC 99       VALUE ZEROS.

   01  MONTH-NUMBER                PIC 99       VALUE ZEROS.

   01  DETAIL-LINE.
       05  ID-CODE-DL              PIC X(3).
       05                          PIC X(3)    VALUE SPACES.
       05                          PIC X(4)    VALUE 'Yr='.
       05  YEAR-NUMBER-DL          PIC Z9      VALUE ZEROS.
       05                          PIC X(4)    VALUE SPACES.
       05                          PIC X(4)    VALUE 'Mo='.
       05  MONTH-NUMBER-DL         PIC Z9.
       05                          PIC X(4)    VALUE SPACES.
       05                          PIC X(5)    VALUE 'Pmt='.
       05  PAYMENT-DL              PIC $$$,$$$.
       05                          PIC X(4)    VALUE SPACES.
       05                          PIC X(5)    VALUE 'Int='.
       05  INTEREST-EARNED-DL      PIC $$$$.99.
       05                          PIC X(3)    VALUE SPACES.
       05                          PIC X(5)    VALUE 'Bal='.
       05  BALANCE-DL              PIC $$$,$$$.99.

   PROCEDURE DIVISION.
   100-MAIN.
       OPEN OUTPUT USED-CAR-FILE-OUT

       PERFORM 200-INPUT THRU 299-EXIT

       CLOSE USED-CAR-FILE-OUT
       STOP RUN.

   200-INPUT.
       DISPLAY 'Used Car Sales Report'
       DISPLAY 'Enter the ID Code (or END) - maximum three char.'
       ACCEPT ID-CODE
       IF ID-CODE = 'END'
           GO TO 299-EXIT
       END-IF
       DISPLAY 'Enter the Total Cash Payment - maximum five digits'
       ACCEPT TOTAL-CASH-PAYMENT
       DISPLAY 'Enter the Monthly Payment - maximum four digits'
       ACCEPT MONTHLY-PAYMENT
       DISPLAY 'Enter the Number of Months - maximum three digits'
       ACCEPT NUMBER-OF-MONTHS
       PERFORM 300-PROCESS.

   299-EXIT.
       EXIT.

   300-PROCESS.
       IF TOTAL-CASH-PAYMENT > 0
           MOVE TOTAL-CASH-PAYMENT TO PAYMENT-DL
       END-IF
       IF MONTHLY-PAYMENT > 0
           MOVE MONTHLY-PAYMENT TO PAYMENT-DL
       END-IF
       ADD PAYMENT-DL TO BALANCE-TOTAL
       COMPUTE INTEREST-EARNED ROUNDED = .0175 / BALANCE-TOTAL
       ADD INTEREST-EARNED TO BALANCE-TOTAL
       MOVE BALANCE-TOTAL TO BALANCE-DL
       ADD 1 TO COMPARE-MONTH
       IF MONTH-NUMBER-DL > 13
           ADD 1 TO MONTH-NUMBER
           MOVE MONTH-NUMBER TO MONTH-NUMBER-DL
       END-IF
       IF MONTH-NUMBER-DL = 13
           MOVE 1 TO MONTH-NUMBER
           MOVE MONTH-NUMBER TO MONTH-NUMBER-DL
       END-IF
       IF MONTH-NUMBER = 1
           ADD 1 TO YEAR-NUMBER
           MOVE YEAR-NUMBER TO YEAR-NUMBER-DL
       END-IF
       MOVE DETAIL-LINE TO USED-CAR-RECORD-OUT
       WRITE USED-CAR-RECORD-OUT
           AFTER ADVANCING 1 LINE
       IF TOTAL-CASH-PAYMENT > 0
           MOVE 0 TO TOTAL-CASH-PAYMENT
           MOVE 0 TO PAYMENT-DL
       END-IF
       IF COMPARE-MONTH > NUMBER-OF-MONTHS
           PERFORM 300-PROCESS
       END-IF

问题在于PAYMENT-DL,INTEREST-EARNED-DL和BALANCE-DL。它说这是一个非法的角色,但我知道它应该有效,因为它在我的书中显示了那些图片条款,老师发出了我必须编写的程序的不完整版本。我该怎么做才能摆脱这些错误?

1 个答案:

答案 0 :(得分:2)

无效字符是“$”符号。

这应该没问题,但您的编译器可能已被自定义为使用本地货币符号作为默认值。

您可以切换到您的本地货币符号(如果您知道!)或将其更改回“$”。将其更改回“$”取决于您使用的编译器以及默认设置的设置方式 - 您确实需要阅读特定编译器的手册以了解如何完成此操作。