Re: Creating a College Grading system using COBOL



On Feb 6, 10:30 pm, LX-i <lxi0...@xxxxxxxxxxxx> wrote:
LX-i wrote:
selworthy wrote:
Does anyone know how to create a program in COBOL using the following
promts (as it would be written in MS Excel)?

=IF(A2>89,"A",IF(A2>79,"B", IF(A2>69,"C",IF(A2>59,"D","F"))))

I have an idea how I'd do it - what have you tried?

Here's what I tried...

identification division.
program-id. GradeMachine.

data division.
working-storage section.

77 inputGrade pic 9(03).
77 outputGrade pic X(01).

procedure division.

display "Please enter the grade"
accept inputGrade

call "AssignGradeLetter"
using inputGrade, outputGrade
end-call

display "The grade is " outputGrade

stop run
.

identification division.
program-id. AssignGradeLetter.

data division.
working-storage section.

01 grades.
12 pic X value "F".
[snip look up table]
12 pic X value "A".
01 gradeTable redefines grades.
12 letterGrade occurs 100 times
indexed by letterGradeIdx
pic X(01).

linkage section.
77 inputGrade pic 9(03).
77 outputGrade pic X(01).

procedure division
using inputGrade outputGrade.

evaluate inputGrade when 1 thru 100
set letterGradeIdx to inputGrade
move letterGrade (letterGradeIdx) to outputGrade
when other
move "?" to outputGrade
end-evaluate
.
end program AssignGradeLetter.

end program GradeMachine.

Looking at the equal widths of most of the class intervals, why not
use linear interpolation instead?

<rhetorical question>

identification division.
program-id. grade.
environment division.
configuration section.
source-computer. ibm-pc.
object-computer. ibm-pc.
data division.
working-storage section.
01 in-num pic 9(3).
01 out-grade pic x.
01 grade-idx pic s9.
01 grades.
05 filler pic x(5) value 'FDCBA'.
01 grade-table redefines grades.
05 letter-grade pic x occurs 5 times.
procedure division.
main.
display 'enter numeric grade'
accept in-num
perform num-to-grade
display 'grade is ' out-grade
stop run
.
num-to-grade.
compute grade-idx = ( in-num - 40 ) / 10
if grade-idx < 1 move 1 to grade-idx end-if
if grade-idx > 5 move 5 to grade-idx end-if
move letter-grade(grade-idx) to out-grade
.

e-mail: epc8 at juno dot com

.



Relevant Pages

  • Re: Creating a College Grading system using COBOL
    ... program-id. ... display "The grade is " outputGrade ... move letterGrade to outputGrade ...
    (comp.lang.cobol)
  • Re: The MOVE problem
    ... PROGRAM-ID. ... MOVEX. ... DATA DIVISION. ... DISPLAY B. ...
    (comp.lang.cobol)
  • Re: Understanding Error Messages
    ... program-id. ... environment devision. ... display "hello" upon console. ... Do you have your compiler settings set to show your listing? ...
    (comp.lang.cobol)
  • Re: Fibonacci program
    ... Fibonacci. ... > PROGRAM-ID. ... > WORKING-STORAGE SECTION. ... > DISPLAY "Fibonacci Sequence" ...
    (comp.lang.cobol)
  • Re: grades
    ... After you take the exam you will get a print out of your score. ... toy certs, it does not display a grade, score, GPA or otherwise, just that ... Do the transcripts display a grade with each exam or an overall ...
    (microsoft.public.cert.exam.mcse)