|
****************************************************************** |
|
* program name: stu1000 |
|
* description: Creates a student list report |
|
* compiler: GnuCOBOL / OpenCOBOL |
|
* author: Kristian Muniz <[email protected]> |
|
* class: SICI 4144 |
|
* date: Wednesday, October 14th, 2016 |
|
****************************************************************** |
|
|
|
identification division. |
|
|
|
program-id. stu1000. |
|
|
|
environment division. |
|
|
|
input-output section. |
|
|
|
file-control. |
|
|
|
select stumast assign to |
|
"c:\users\kris\documents\stu1000\stumast.dat". |
|
select stulist assign to |
|
"c:\users\kris\documents\stu1000\stulist.lprt". |
|
|
|
data division. |
|
|
|
file section. |
|
|
|
fd stumast. |
|
|
|
01 student-master-record. |
|
05 sm-student-id pic 9(9). |
|
05 sm-student-status pic X. |
|
88 enrolled value "E". |
|
88 inactive value "I". |
|
|
|
05 sm-student-name-and-address. |
|
10 sm-student-name pic x(25). |
|
10 sm-date-of-birth. |
|
15 sm-dob-year pic 9(4). |
|
15 sm-dob-month pic 9(2). |
|
15 sm-dob-year pic 9(2). |
|
10 sm-student-address pic x(25). |
|
10 sm-student-city pic x(11). |
|
10 sm-student-state pic x(2). |
|
10 sm-zip-code pic 9(5). |
|
10 sm-zip-code-ext pic 9(4). |
|
|
|
05 sm-student-progress-summary. |
|
10 sm-class-standing pic 9. |
|
88 freshman value 1. |
|
88 sophomore value 2. |
|
88 junior value 3. |
|
88 senior value 4. |
|
10 sm-major pic x(4). |
|
10 sm-units-completed pic 9(3). |
|
10 sm-total-grade-points pic 9(3). |
|
10 sm-units-in-progress pic 9(3). |
|
|
|
fd stulist. |
|
|
|
01 print-area pic x(132). |
|
|
|
working-storage section. |
|
|
|
01 switches. |
|
05 stumast-eof-switch pic x value "N". |
|
88 stumast-eof value "Y". |
|
|
|
01 print-fields. |
|
05 page-count pic s9(3) value 0. |
|
05 lines-on-page pic s9(3) value +55. |
|
05 line-count pic s9(3) value +99. |
|
05 space-control pic s9. |
|
|
|
01 total-fields. |
|
05 total-students pic 9(5) value 0. |
|
|
|
01 calculated-fields. |
|
05 student-gpa pic 9v99. |
|
|
|
01 current-date-and-time. |
|
05 cd-year pic 9999. |
|
05 cd-month pic 99. |
|
05 cd-day pic 99. |
|
05 cd-hours pic 99. |
|
05 cd-minutes pic 99. |
|
05 filler pic x(9). |
|
|
|
01 heading-line-1. |
|
05 filler pic x(7) value "DATE: ". |
|
05 hl1-month pic 9(2). |
|
05 filler pic x(1) value "/". |
|
05 hl1-day pic 9(2). |
|
05 filler pic x(1) value "/". |
|
05 hl1-year pic 9(4). |
|
05 filler pic x(2) value space. |
|
05 filler pic x(20) value "STUDENT LISTING ". |
|
05 filler pic x(20) value space. |
|
05 filler pic x(15) value " PAGE: ". |
|
05 hl1-page-number pic zzz9. |
|
05 filler pic x(37) value space. |
|
|
|
01 heading-line-2. |
|
05 filler pic x(7) value "TIME: ". |
|
05 hl2-hours pic 9(2). |
|
05 filler pic x(1) value ":". |
|
05 hl2-minutes pic 9(2). |
|
05 filler pic x(58) value space. |
|
05 filler pic x(10) value "STU_1000". |
|
05 filler pic x(52) value space. |
|
|
|
01 heading-line-3. |
|
05 filler pic x(20) value "STUDENT ID STUDENT". |
|
05 filler pic x(10) value " NAME ". |
|
05 filler pic x(10) value space. |
|
05 filler pic x(20) value "CLASS GPA ". |
|
05 filler pic x(116) value space. |
|
|
|
01 working-fields. |
|
05 wk-student-id pic XXXBXXBXXXX. |
|
|
|
01 student-line. |
|
05 sl-student-id-formatted. |
|
10 first-three pic x(3). |
|
10 filler pic x(1) value '-'. |
|
10 middle-two pic x(2). |
|
10 filler pic x(1) value '-'. |
|
10 last-four pic x(4). |
|
05 filler pic x(2) value space. |
|
05 sl-student-name pic x(25). |
|
05 filler pic x(2) value space. |
|
05 sl-student-class pic x(9). |
|
05 filler pic x(2) value space. |
|
05 sl-student-gpa pic 9.99. |
|
05 filler pic x(77) value space. |
|
|
|
01 total-line. |
|
05 filler pic x(16) value "TOTAL STUDENTS: ". |
|
05 tl-students pic ZZ,ZZ9. |
|
05 filler pic x(110) value space. |
|
|
|
procedure division. |
|
|
|
000-prepare-student-report. |
|
|
|
open input stumast |
|
output stulist. |
|
|
|
perform 100-format-report-heading. |
|
|
|
perform 200-prepare-student-lines |
|
until stumast-eof-switch = "Y". |
|
|
|
perform 300-print-totals. |
|
|
|
close stumast |
|
stulist. |
|
|
|
stop run. |
|
|
|
100-format-report-heading. |
|
|
|
move function current-date to current-date-and-time. |
|
move cd-month to hl1-month. |
|
move cd-day to hl1-day. |
|
move cd-year to hl1-year. |
|
move cd-hours to hl2-hours. |
|
move cd-minutes to hl2-minutes. |
|
|
|
200-prepare-student-lines. |
|
|
|
perform 210-read-student-record. |
|
|
|
if stumast-eof-switch = "N" |
|
perform 220-print-student-line. |
|
|
|
210-read-student-record. |
|
|
|
read stumast |
|
at end |
|
set stumast-eof to true. |
|
|
|
220-print-student-line. |
|
|
|
if line-count >= lines-on-page |
|
perform 230-print-heading-lines. |
|
|
|
move sm-student-id to wk-student-id. |
|
move wk-student-id to sl-student-id-formatted. |
|
move sm-student-name to sl-student-name. |
|
move sm-class-standing to sl-student-class. |
|
|
|
evaluate true |
|
when freshman |
|
move 'FRESHMAN' to sl-student-class |
|
when sophomore |
|
move 'SOPHOMORE' to sl-student-class |
|
when junior |
|
move 'JUNIOR' to sl-student-class |
|
when other |
|
move 'SENIOR' to sl-student-class |
|
end-evaluate. |
|
|
|
compute sl-student-gpa = |
|
(sm-total-grade-points / sm-units-completed). |
|
|
|
move student-line to print-area. |
|
|
|
write print-area after advancing space-control lines. |
|
|
|
add 1 to total-students. |
|
add 1 to line-count. |
|
move 1 to space-control. |
|
|
|
230-print-heading-lines. |
|
|
|
add 1 to page-count. |
|
|
|
move page-count to hl1-page-number. |
|
|
|
move heading-line-1 to print-area. |
|
write print-area after advancing page. |
|
|
|
move heading-line-2 to print-area. |
|
write print-area after advancing 1 lines. |
|
|
|
move heading-line-3 to print-area. |
|
write print-area after advancing 2 lines. |
|
|
|
move zero to line-count. |
|
move 2 to space-control. |
|
|
|
300-print-totals. |
|
|
|
move total-students to tl-students. |
|
move total-line to print-area. |
|
write print-area after advancing 2 lines. |