Re: Creating a College Grading system using COBOL
- From: epc8@xxxxxxxx
- Date: 7 Feb 2007 20:33:21 -0800
On Feb 6, 10:30 pm, LX-i <lxi0...@xxxxxxxxxxxx> wrote:
LX-i wrote:[snip look up table]
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".
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
.
- References:
- Creating a College Grading system using COBOL
- From: selworthy
- Re: Creating a College Grading system using COBOL
- From: LX-i
- Re: Creating a College Grading system using COBOL
- From: LX-i
- Creating a College Grading system using COBOL
- Prev by Date: Re: My First C# (warning - long post)
- Next by Date: Re: Creating a College Grading system using COBOL
- Previous by thread: Re: Creating a College Grading system using COBOL
- Next by thread: Re: Creating a College Grading system using COBOL
- Index(es):
Relevant Pages
|