Question
How can I enhance and get this COBOL code to include at the bottom of the EXAM4 text file , the student number, student name,
How can I enhance and get this COBOL code to include at the bottom of the EXAM4 text file, the student number, student name, and total tuition fees for each student?
** THE INPUT FILE "EXAM4.DAT" Contains the bolded information below, then the coding I already have begins at "Identification Division"**
*** There are 3 syntax errors and 4 logical errors in the code that needs to be fixed****
12345SMITH, ROBERT 0031500 56566JOHNSON, RENATA 1187975 83457DONNELLY, ALICE 0950000 66321GREEN, PETER 0174565 16734STEWART, JOHN 0001700 56584REYNOLDS, BILL 0087890 83577MILLER, PRISCILLA 0150000 64621MORRIS, RALPH 0167787
-------------------------------------------------------------------------------------Coding I have is below this line-------------------------------
IDENTIFICATION DIVISION. PROGRAM-ID. F16. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. PC. OBJECT-COMPUTER. PC. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT STUDENT-FILE ASSIGN TO 'C:\COBOL\EXAM4.DAT' ORGANIZATION IS LINE SEQUENTIAL. SELECT TUTION-REPORT ASSIGN TO 'C:\COBOL\EXAM4.TXT' ORGANIZATION IS LINE SEQUENTIAL. DATA DIVISION. FILE SECTION. FD STUDENT-FILE LABEL RECORDS ARE STANDARD RECORD CONTAINS 30 CHARACTERS. 01 STU-REC-IN. 05 STU-NO-IN PIC X(5). 05 STU-NAME-IN PIC X(20). 05 TUITION-AM-IN PIC 9(5)V99. FD TUTION-REPORT LABEL RECORDS ARE OMITTED RECORD CONTAINS 132 CHARACTERS. 01 PRINT-REC PIC X(132). WORKING-STORAGE SECTION. 01 WORK-AREAS. 05 ARE-THERE-MORE-RECORDS PIC XXX VALUE 'NO '. 05 WS-DATE. 10 WS-YEAR PIC 9999. 10 WS-MONTH PIC 99. 10 WS-DAY PIC 99. 05 WS-PAGE-COUNT PIC 99 VALUE ZERO. 05 WS-LINE-COUNT PIC 99 VALUE ZERO. 01 HDR1-OUT. 05 PIC X(40) VALUE SPACES. 05 PIC X(20) VALUE 'TUITION REPORT'. 05 DATE-OUT. 10 MONTH-OUT PIC 99. 10 PIC X VALUE '/'. 10 DAY-OUT PIC 99. 10 PIC X VALUE '/'. 10 YEAR-OUT PIC 9999. 05 PIC X(2) VALUE SPACES. 05 PIC X(5) VALUE 'PAGE'. 05 PAGE-OUT PIC Z9. 05 PIC X(55) VALUE SPACES. 01 HDR2-OUT. 05 PIC X(10) VALUE SPACES. 05 PIC X(27) VALUE 'STUDENT NO STUDENT NAME'. 05 PIC X(13) VALUE SPACES. 05 PIC X(82) VALUE 'TOTAL TUTION FEES '. 01 DETAIL-REC-OUT. 05 PIC X(13) VALUE SPACES. 05 STU-NO-OUT PIC X(5). 05 PIC X(6) VALUE SPACES. 05 STU-NAME-OUT PIC X(20). 05 PIC X(11) VALUE SPACES. 05 TUITION-AM-OUT PIC Z(5).99. 05 PIC X(69) VALUE SPACES. PROCEDURE DIVISION.
100-MAIN-MODULE. OPEN INPUT STUDENT-FILE OUTPUT TUTION-REPORT MOVE FUNCTION CURRENT-DATE TO WS-DATE MOVE WS-MONTH TO MONTH-OUT MOVE WS-DAY TO DAY-OUT MOVE WS-YEAR TO YEAR-OUT PERFORM 200-HEADER-RTN. PERFORM UNTIL ARE-THERE-MORE-RECORDS = 'NO ' READ STUDENT-FILE AT END MOVE 'NO ' TO ARE-THERE-MORE-RECORDS NOT AT END PERFORM 300-REPORT-RTN END-READ END-PERFORM CLOSE STUDENT-FILE TUTION-REPORT STOP RUN.
200-HEADER-RTN. ADD 1 TO WS-PAGE-COUNT MOVE WS-DAY TO PAGE-OUT WRITE PRINT-REC FROM HDR1-OUT AFTER ADVANCING PAGE WRITE PRINT-REC FROM HDR2-OUT AFTER ADVANCING 2 LINES MOVE ZEROS TO WS-LINE-COUNT.
300-REPORTRTN. IF WS-LINE-COUNT >= 2 PERFORM 200-HEADER-RTN END-IF MOVE SPACES TO DETAIL-REC-OUT MOVE STU-NO-IN TO STU-NO-OUT MOVE STU-NAME-IN TO STU-NAME-OUT MOVE STU-NO-IN TO TUITION-AM-OUT WRITE PRINT-REC FROM DETAIL-REC-OUT AFTER ADVANCING 2 LINES ADD 1 TO WS-LINECOUNT.
----------------------------------------------------------Under this line is what the completed EXAM4 text file is supposed to look like. (After the 3 syntax errors and 4 logical errors are fixed)-----------------
TUITION REPORT 12/07/2016 PAGE 1
STUDENT NO STUDENT NAME TOTAL TUTION FEES
12345 SMITH, ROBERT 315.00
56566 JOHNSON, RENATA 11879.75
83457 DONNELLY, ALICE 9500.00
66321 GREEN, PETER 1745.65
16734 STEWART, JOHN 17.00
56584 REYNOLDS, BILL 878.90
83577 MILLER, PRISCILLA 1500.00
64621 MORRIS, RALPH 1677.87
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started