Problem on COBOL if sentence

Write a COBOL IF sentence to use the values of numeric variables EXAM and COURSEWORK, both assumed to be with format PIC 999 and in the range 0 to 100 and to move the value:
“FAIL”,
“RC” ( resit coursework),
“RE” (resit examination”),
“RB” (resit both examination and coursework) or
“PASS”
 to the variable RESULT with format PIC XXXX, according to this flowchart:

1201_cobol.jpg

E

Expert

Verified

Using EVALUATE is easier, but since asked to use IF
Assume Passing mark is 50

01 EXAM PIC 999
01 COURSEWORK PIC 999
01 RESULT PIC X(4)
 
ACCEPT EXAM.
ACCEPT COURSEWORK.

IF EXAM<30 AND COURSEWORK<30
    MOVE ‘FAIL’ TO RESULT
IF EXAM>39 AND (COURSEWORK>29 AND COURSEWORK<40)
    MOVE ‘RC’ TO RESULT
IF (EXAM>29 AND EXAM<40) AND COURSEWORK>49
    MOVE ‘RE’ TO RESULT
IF (EXAM>29 AND EXAM<40) AND(COURSEWORK>29 AND COURSEWORK<40)
    MOVE ‘RB’TO RESULT
IF EXAM>39AND COURSEWORK>39
    MOVE ‘PASS’ TO RESULT
DISPLAY RESULT.

   Related Questions in Programming Languages

©TutorsGlobe All rights reserved 2022-2023.