Now, I only have a passing familiarity with COBOL, but if I recall correctly,
05 WF-Grade pic 99.
as a 2-digit decimal value, right? Whereas in Init-Rtn
, you use it first as a character value, then as a decimal:
Display 'Please enter your grade & press enter key'
If WF-Grade = 'A'
Add 4 to WF-Grade
If WF-Grade = 'B'
Add 3 to WF-Grade
If WF-Grade = 'C'
Add 2 to WF-Grade
If WF-Grade = 'D'
Add 1 to WF-Grade
If WF-Grade = 'F'
Add 0 to WF-Grade
Furthermore, there's no short-circuiting of the tests; even once you have the numeric value of WF-Grade
assigned, you are still comparing it (up to four times) with a character value.
I suspect what you meant to do is have another variable, say,
05 WF-Letter-Grade pic X.
in which to hold the letter grade. For the other part, once you fix the variables it shouldn't make a difference for the program flow, but it may slow things down a bit; I think you'd be better off replacing the IF statements with a SEARCH
on a table with the pairs of letter grades and grade values (don't recall how you do that offhand, or even if I have the keyword right). Otherwise, you'll need to use nested IF/ELSE/END-IF
s to avoid repeatedly testing the value unnecessarily.
It sounds like whatever compiler you're using is very
lax on syntax checking...