我正在本学期完成上一次为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上。它说这是一个非法字符,但我知道它应该起作用,因为它显示了我的书中的那些pic子句,而老师则分发了我必须编写的程序的不完整版本。我该怎么办才能消除这些错误?
最佳答案
无效字符是“$”符号。
这应该可以,但是您的编译器可能已被自定义为使用本地货币符号作为默认值。
您可以切换到您的本地货币符号(如果您知道的话!)或将其更改回“$”。将其更改回“$”取决于您使用的是哪个编译器以及如何设置默认值-您确实需要阅读特定编译器的手册以了解如何完成此操作。
关于syntax-error - 在语法错误(COBOL)方面需要帮助,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4392557/