在我的一项课堂作业中,我遇到了有关我的程序部门的错误。这是一个 COBOL 程序,应该保持申请人的平均身高和体重、棕色眼睛的申请人数、男性申请人数和女性申请人数的总和。此外,该程序应该打印满足特定要求的申请人的信息,但我的几乎所有执行语句都出现错误
COBCH0034 操作数操作数应该是数字 在此上下文中需要一个数字值,并且您指定了一个非数字值。
COBCH0014 操作数无效 您指定的操作数在某种程度上不正确,您的 COBOL 系统无法处理。例如,您可能指定了一个负整数,其中只允许使用正整数
identification division.
program-id. ELECTRA-MODELING-AGENCY.
******************************************************************
*THIS PROGRAM PRODUCES THE REPORT ACCORDING TO THE GIVEN PRINTER
*SPACING CHART *
******************************************************************
environment division.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INPUT-FILE ASSIGN TO "INFILE.txt"
Organization is line sequential.
SELECT OUTPUT-FILE ASSIGN TO "CHOSEN-APLICANTS.TXT"
Organization is line sequential.
data division.
FILE SECTION.
FD INPUT-FILE.
01 INPUT-REC.
05 APPLICANTS-NAME PIC X(20).
05 APPLICANTS-WEIGHT PIC 9(3).
05 APPLICANTS-HEIGHT PIC 9(2).
05 APPLICANTS-EYE-CODE PIC X.
05 APPLICANTS-HAIR-CODE PIC X.
05 APPLICANTS-GENDER PIC X.
FD OUTPUT-FILE.
01 OUTPUT-REC PIC X(78).
WORKING-STORAGE SECTION.
01 EOF PIC X VALUE "N".
01 HEADING-1.
05 FILLER PIC X(41) VALUE "M"
JUSTIFIED RIGHT.
05 FILLER PIC X(2) VALUE "O"
JUSTIFIED RIGHT.
05 FILLER PIC X(2) VALUE "D"
JUSTIFIED RIGHT.
05 FILLER PIC X(2) VALUE "E"
JUSTIFIED RIGHT.
05 FILLER PIC X(2) VALUE "L"
JUSTIFIED RIGHT.
05 FILLER PIC X(3) VALUE "R"
JUSTIFIED RIGHT.
05 FILLER PIC X(2) VALUE "E"
JUSTIFIED RIGHT.
05 FILLER PIC X(2) VALUE "P"
JUSTIFIED RIGHT.
05 FILLER PIC X(2) VALUE "O"
JUSTIFIED RIGHT.
05 FILLER PIC X(2) VALUE "R"
JUSTIFIED RIGHT.
05 FILLER PIC X(2) VALUE "T"
JUSTIFIED RIGHT.
05 FILLER PIC X(16) VALUE SPACES.
01 HEADING-2.
05 FILLER PIC X(23) VALUE "NAME"
JUSTIFIED RIGHT.
05 FILLER PIC X(13) VALUE "SEX"
JUSTIFIED RIGHT.
05 FILLER PIC X(10) VALUE "WEIGHT"
JUSTIFIED RIGHT.
05 FILLER PIC X(8) VALUE "HEIGHT"
JUSTIFIED RIGHT.
05 FILLER PIC X(5) VALUE "EYE"
JUSTIFIED RIGHT.
05 FILLER PIC X(6) VALUE "COLOR"
JUSTIFIED RIGHT.
05 FILLER PIC X(6) VALUE "HAIR"
JUSTIFIED RIGHT.
05 FILLER PIC X(6) VALUE "COLOR"
JUSTIFIED RIGHT.
05 FILLER PIC X VALUE SPACES.
01 DETAIL-LINE.
05 FILLER PIC X(10) VALUE SPACES.
05 NAME-OUT PIC X(20).
05 FILLER PIC X(4) VALUE SPACES.
05 GENDER-OUT PIC X.
05 FILLER PIC X(6) VALUE SPACES.
05 WEIGHT-OUT PIC X(3).
05 FILLER PIC X(6) VALUE SPACES.
05 HEIGHT-OUT PIC XX.
05 FILLER PIC X(6) VALUE SPACES.
05 EYE-COLOR-OUT PIC X(5).
05 FILLER PIC X(6) VALUE SPACES.
05 HAIR-COLOR-OUT PIC X(6).
01 SUMMARY-LINE-01
05 FILLER PIC X(17) VALUE "AVERAGE"
JUSTIFIED RIGHT.
05 FILLER PIC X(7) VALUE "HEIGHT"
JUSTIFIED RIGHT.
05 FILLER PIC X(3) VALUE "OF"
JUSTIFIED RIGHT.
05 FILLER PIC X(4) VALUE "ALL"
JUSTIFIED RIGHT.
05 FILLER PIC X(12) VALUE "APPLICANTS:"
JUSTIFIED RIGHT.
05 FILLER PIC X.
05 AVERAGE-HEIGHT PIC ZZZ9.
05 FILLER PIC X(12) VALUE SPACES.
01 SUMMARY-LINE-02
05 FILLER PIC X(17) VALUE "AVERAGE"
JUSTIFIED RIGHT.
05 FILLER PIC X(7) VALUE "WEIGHT"
JUSTIFIED RIGHT.
05 FILLER PIC X(3) VALUE "OF"
JUSTIFIED RIGHT.
05 FILLER PIC X(4) VALUE "ALL"
JUSTIFIED RIGHT.
05 FILLER PIC X(12) VALUE "APPLICANTS:"
JUSTIFIED RIGHT.
05 FILLER PIC X.
05 AVERAGE-WEIGHT PIC ZZZ9.
05 FILLER PIC X(12) VALUE SPACES.
01 SUMMARY-LINE-03
05 FILLER PIC X(16) VALUE "NUMBER"
JUSTIFIED RIGHT.
05 FILLER PIC X(3) VALUE "OF"
JUSTIFIED RIGHT.
05 FILLER PIC X(11) VALUE "BROWN-EYED"
JUSTIFIED RIGHT.
05 FILLER PIC X(12) VALUE "APPLICANTS:"
JUSTIFIED RIGHT.
05 FILLER PIC XX.
05 BROWN-EYED-APPLICANTS PIC ZZZ9.
05 FILLER PIC X(12) VALUE SPACES.
01 SUMMARY-LINE-04
05 FILLER PIC X(16) VALUE "NUMBER"
JUSTIFIED RIGHT.
05 FILLER PIC X(3) VALUE "OF"
JUSTIFIED RIGHT.
05 FILLER PIC X(5) VALUE "MALE"
JUSTIFIED RIGHT.
05 FILLER PIC X(12) VALUE "APPLICANTS:"
JUSTIFIED RIGHT.
05 FILLER PIC X(8) VALUE SPACES.
05 MALE-APPLICANTS PIC ZZZ9.
05 FILLER PIC X(12) VALUE SPACES.
01 SUMMARY-LINE-05
05 FILLER PIC X(16) VALUE "NUMBER"
JUSTIFIED RIGHT.
05 FILLER PIC X(3) VALUE "OF"
JUSTIFIED RIGHT.
05 FILLER PIC X(7) VALUE "FEMALE"
JUSTIFIED RIGHT.
05 FILLER PIC X(11) VALUE "APPLICANTS:"
JUSTIFIED RIGHT.
05 FILLER PIC X(6) VALUE SPACES.
05 FEMALE-APPLICANTS PIC ZZZ9.
05 FILLER PIC X(12) VALUE SPACES.
procedure division.
100-main.
OPEN INPUT INPUT-FILE
OUTPUT OUTPUT-FILE
PERFORM UNTIL EOF = 'Y'
READ INPUT-FILE
AT END MOVE 'Y' TO EOF
NOT AT END
PERFORM 200-HEADING.
PERFORM 200-AVG-HEIGHT.
PERFORM 200-AVG-WEIGHT.
PERFORM 200-BROWN-EYED-APPS.
PERFORM 200-MALE-APPS.
PERFORM 200-FEMALE-APPS.
PERFORM 200-MALE-DETAIL-LINE.
PERFORM 200-FEMALE-DETAIL-LINE.
CLOSE INPUT-FILE, OUTPUT-FILE.
STOP RUN.
200-HEADING.
WRITE OUTPUT-REC FROM HEADING-1.
MOVE SPACES TO OUTPUT-REC.
WRITE OUTPUT-REC.
WRITE OUTPUT-REC FROM HEADING-2.
MOVE SPACES TO OUTPUT-REC.
WRITE OUTPUT-REC.
200-AVG-HEIGHT.
IF NOT AT END
ADD APPLICANTS-HEIGHT TO AVERAGE-HEIGHT
ELSE AT END
DIVIDE AVERAGE-HEIGHT BY 21.
WRITE OUTPUT-REC FROM SUMMARY-LINE-01.
200-AVG-WEIGHT.
IF NOT AT END
ADD APPLICANTS-WEIGHT TO AVERAGE-WEIGHT
ELSE AT END
DIVIDE AVERAGE-HEIGHT BY 21.
WRITE OUTPUT-REC FROM SUMMARY-LINE-02.
200-BROWN-EYED-APPS.
IF APPLICANTS-EYE-CODE = 2
ADD 1 TO BROWN-EYED-APPLICANTS
ELSE CONTINUE.
WRITE OUTPUT-REC FROM SUMMARY-LINE-03.
200-MALE-APPS.
IF APPLICANTS-GENDER = M
ADD 1 TO MALE-APPLICANTS
ELSE CONTINUE.
WRITE OUTPUT-REC FROM SUMMARY-LINE-04.
200-FEMALE-APPS.
IF APPLICANTS-GENDER = F
ADD 1 TO FEMALE-APPLICANTS
ELSE CONTINUE.
WRITE OUTPUT-REC FROM SUMMARY-LINE-05.
200-MALE-DETAIL-LINE.
IF APPLICANTS-HAIR-CODE = 1
IF APPLICANTS-EYE-CODE = 1
IF APPLICANTS-GENDER = M
IF APPLICANTS-HEIGHT >= 72
IF 185 <= APPLICANTS-WEIGHT <= 200
ELSE CONTINUE.
WRITE OUTPUT-REC FROM 01 DETAIL-LINE.
200-FEMALE-DETAIL-LINE.
IF APPLICANTS-HAIR-CODE = 2
IF APPLICANTS-EYE-CODE = 2
IF APPLICANTS-GENDER = F
IF 62 <= APPLICANTS-HEIGHT <= 64
IF 110 <= APPLICANTS-WEIGHT <= 125
ELSE CONTINUE.
WRITE OUTPUT-REC FROM 01 DETAIL-LINE.
end program ELECTRA-MODELING-AGENCY.