I am currently writing a program for my Cobol class to calculate the tuition of students. However, I keep getting syntax errors:
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
I have tried deleting moving it elsewhere, checked spelling, and can not seem to get rid of these errors.
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.
I am in my third week of class and besides a sample program that was given to us, this is the first I have tried to write.
Two things. First, as was mentioned before field names cannot have spaces in them. Second: A period ends a statement not a verb. Don't use them unless you have to, which is only at the end of a paragraph; the scope terminators by themselves are are fine unless it's on the last statement in a paragraph.
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. <- This period ends the statement not just the read
END-PERFORM. <- leaving this hanging