我正在为我的COBOL课程编写一个计算学生学费的程序。但是,我一直在遇到语法错误:
jdoodle.cobc: in Paragraph '100-MAIN-Module':
jdoodle.cobc:33: error: syntax error, unexpected END
jdoodle.cobc:36: error: syntax error, unexpected END
jdoodle.cobc:40: error: syntax error, unexpected END-PERFORM
我尝试了删除、移动位置,检查拼写,但似乎无法摆脱这些错误。
IDENTIFICATION DIVISION.
PROGRAM-ID. Tuition.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT IN-STUDENT-FILE
ASSIGN TO 'name.dat'
ORGANIZATION IS LINE SEQUENTIAL.
SELECT OUT-STUDENT-FILE
ASSIGN TO 'tuition.dat'
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD IN-STUDENT-FILE.
01 IN-STUDENT-REC.
05 STUDENTNAME-IN PICTURE X(20).
05 NUMCRED-IN PICTURE 99.
05 PICTURE X(58).
FD OUT-STUDENT-FILE.
01 OUT-STUDENT-REC.
05 STUDENTNAME-OUT PICTURE X(20).
05 PICTURE X(20).
05 NUMCRED-OUT PICTURE 99.
05 PICTURE X(20).
05 TUITION-OUT PICTURE X(4).
WORKING-STORAGE SECTION.
01 TUITION PICTURE 9(4).
01 EOF PICTURE X.
PROCEDURE DIVISION.
100-MAIN-MODULE.
OPEN INPUT IN-STUDENT-FILE
OUTPUT OUT-STUDENT-FILE
PERFORM UNTIL END OF FILE = 'YES'
READ IN-STUDENT-FILE
AT END
MOVE 'YES' TO END OF FILE
NOT AT END
PERFORM 200-PROCESS-RTN
END-READ.
END-PERFORM.
CLOSE IN-STUDENT-FILE
OUT-STUDENT-FILE
STOP RUN.
200-PROCESS-RTN.
MOVE STUDENTNAME-IN TO STUDENTNAME-OUT
MOVE NUMCRED-IN TO NUMCRED-OUT
IF NUMCRED-IN < 12 THEN
MULTIPLY NUMCRED-IN BY 525 GIVING TUITION
ELSE
SET TUITION TO 6300
END-IF
MOVE TUITION TO TUITION-OUT
DISPLAY OUT-STUDENT-REC
WRITE OUT-STUDENT-REC.
我已经上了三个星期的课,在老师给我们的一个样例程序之外,这是我第一次尝试编写代码。