EDIT ASSIGNMENT: Analyze the program and then answer the questions below.
IDENTIFICATION DIVISION. PROGRAM-ID. EDITINCL. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT FILE-EDIT ASSIGN TO "C:\PCOBWIN\CIS12FST\EDITINCL.DAT". SELECT VALID-EDIT ASSIGN TO "C:\PCOBWIN\CIS12FST\EDITGOOD.DAT". SELECT PRINT-FILE ASSIGN TO "C:\PCOBWIN\CIS12FST\EDITERR.DAT". DATA DIVISION. FILE SECTION. FD FILE-EDIT DATA RECORD IS REC-EDIT. 01 REC-EDIT PIC X(57). FD VALID-EDIT DATA RECORD IS VALID-REC. 01 VALID-REC PIC X(57). FD PRINT-FILE DATA RECORD IS PRINTZ. 01 PRINTZ PIC X(81). WORKING-STORAGE SECTION. 01 INDICATORS. 05 MORE-RECS PIC XXX VALUE "YES". 05 VALID-REC-IND PIC XXX VALUE "YES". 88 GOOD-REC VALUE "YES". 88 INVALID-REC VALUE "NO ". 01 EDIT-AREA. 05 ITEM-NO PIC 9(6). 05 RDF-ITEM-NO REDEFINES ITEM-NO PIC X(6). 05 ITEM-NAME PIC X(20). 05 DEPT PIC XXXXX. 88 VALID-DEPT VALUE "MEN " "WOMEN" "GIRLS" "BOYS ". 05 ON-HAND PIC 9(5). 05 RDF-ON-HAND REDEFINES ON-HAND PIC X(5). 05 ON-ORDER PIC 9(5). 05 RDF-ON-ORDER REDEFINES ON-ORDER PIC X(5). 05 RE-ORDER-PT PIC 9(5). 05 RDF-RE-ORDER-PT REDEFINES RE-ORDER-PT PIC X(5). 05 COST PIC 999V99. 05 RDF-COST REDEFINES COST PIC X(5). 05 PRICE PIC 9999V99. 05 RDF-PRICE REDEFINES PRICE PIC X(6). 01 EDIT-LINE. 05 FILLER PIC X(1) VALUE SPACES. 05 ITEM-NO-PR PIC X(6) VALUE SPACES. 05 FILLER PIC X(5) VALUE SPACES. 05 DATA-IN-ERROR PIC X(20) VALUE SPACES. 05 FILLER PIC X(5) VALUE SPACES. 05 MSG-PR PIC X(30) VALUE SPACES. 05 FILLER PIC X(14) VALUE SPACES. PROCEDURE DIVISION. MAINLINE. PERFORM A-100-STARTUP. PERFORM B-100-PROCESS. PERFORM C-100-WRAPUP. STOP RUN. A-100-STARTUP. OPEN INPUT FILE-EDIT OUTPUT VALID-EDIT PRINT-FILE. B-100-PROCESS. READ FILE-EDIT INTO EDIT-AREA AT END MOVE "NO " TO MORE-RECS. PERFORM B-200-LOOP UNTIL MORE-RECS = "NO ". B-200-LOOP. MOVE "YES" TO VALID-REC-IND. PERFORM B-300-EDIT-RECORD. IF GOOD-REC MOVE EDIT-AREA TO VALID-REC WRITE VALID-REC. READ FILE-EDIT INTO EDIT-AREA AT END MOVE "NO " TO MORE-RECS. B-300-EDIT-RECORD. MOVE SPACES TO EDIT-LINE. IF ITEM-NO IS NOT NUMERIC MOVE RDF-ITEM-NO TO DATA-IN-ERROR MOVE "ITEM NUMBER NOT NUMERIC" TO MSG-PR PERFORM U-100-WRITE-ERROR END-IF IF ITEM-NAME = SPACES MOVE "ITEM NAME IS BLANK" TO MSG-Pr PERFORM U-100-WRITE-ERROR END-IF IF NOT VALID-DEPT MOVE DEPT TO DATA-IN-ERROR MOVE "INVALID DEPT NAME" TO MSG-PR PERFORM U-100-WRITE-ERROR END-IF IF ON-HAND NOT NUMERIC MOVE RDF-ON-HAND TO DATA-IN-ERROR MOVE "ON HAND NOT NUMERIC" TO MSG-PR PERFORM U-100-WRITE-ERROR END-IF IF ON-ORDER NOT NUMERIC MOVE RDF-ON-ORDER TO DATA-IN-ERROR MOVE "ON ORDER NOT NUMERIC" TO MSG-PR PERFORM U-100-WRITE-ERROR END-IF IF RE-ORDER-PT NOT NUMERIC MOVE RDF-RE-ORDER-PT TO DATA-IN-ERROR MOVE "REORDER POINT NOT NUMERIC" TO MSG-PR PERFORM U-100-WRITE-ERROR ELSE IF RE-ORDER-PT = 0 MOVE RE-ORDER-PT TO DATA-IN-ERROR MOVE "REORDER POINT ZERO" TO MSG-PR PERFORM U-100-WRITE-ERROR END-IF END-IF IF COST NOT NUMERIC MOVE RDF-COST TO DATA-IN-ERROR MOVE "COST NOT NUMERIC" TO MSG-PR PERFORM U-100-WRITE-ERROR END-IF IF PRICE NOT NUMERIC MOVE RDF-PRICE TO DATA-IN-ERROR MOVE "PRICE NOT NUMERIC" TO MSG-PR PERFORM U-100-WRITE-ERROR END-IF IF PRICE NUMERIC AND COST NUMERIC AND PRICE LESS THAN COST MOVE RDF-PRICE TO DATA-IN-ERROR MOVE "PRICE LESS THAN COST" TO MSG-PR PERFORM U-100-WRITE-ERROR END-IF END-IF. C-100-WRAPUP. CLOSE FILE-EDIT VALID-EDIT PRINT-FILE. U-100-WRITE-ERROR. MOVE RDF-ITEM-NO TO ITEM-NO-PR. MOVE "NO " TO VALID-REC-IND. WRITE PRINTZ FROM EDIT-LINE AFTER ADVANCING 1 LINES.
Question #1: B-200-LOOP control code can be written several ways - circle all code that would work and explain problems.
Way #1: |
B-200-LOOP. PERFORM B-300-EDIT-RECORD. MOVE "YES" TO VALID-REC-IND. IF GOOD-REC MOVE EDIT-AREA TO VALID-REC WRITE VALID-REC. READ FILE-EDIT INTO EDIT-AREA AT END MOVE "NO " TO MORE-RECS. |
Way #2: |
B-200-LOOP. MOVE "YES" TO VALID-REC-IND. PERFORM B-300-EDIT-RECORD. IF GOOD-REC MOVE EDIT-AREA TO VALID-REC WRITE VALID-REC. READ FILE-EDIT INTO EDIT-AREA AT END MOVE "NO " TO MORE-RECS. |
Way #3: |
B-200-LOOP. MOVE "YES" TO VALID-REC-IND. PERFORM B-300-EDIT-RECORD. IF VALID-REC-IND = "YES" MOVE EDIT-AREA TO VALID-REC WRITE VALID-REC. READ FILE-EDIT INTO EDIT-AREA AT END MOVE "NO " TO MORE-RECS. |
Way #4: |
B-200-LOOP. MOVE "YES" TO VALID-REC-IND. PERFORM B-300-EDIT-RECORD. IF INVALID-REC NEXT SENTENCE ELSE MOVE EDIT-AREA TO VALID-REC WRITE VALID-REC. READ FILE-EDIT INTO EDIT-AREA AT END MOVE "NO " TO MORE-RECS END-READ END-IF. |
Question #2: Circle all code that is correct - explain problem with any that are wrong.
Way #1: |
READ FILE-EDIT AT END MOVE "NO " TO MORE-RECS. MOVE REC-EDIT TO EDIT-AREA. |
Way #2: |
READ FILE-EDIT INTO EDIT-AREA AT END MOVE "NO " TO MORE-RECS. |
Wat #3: |
READ FILE-EDIT AT END MOVE "NO " TO MORE-RECS END-READ. |
Data being read: (EDITINCL.DAT)
121212SKIRT WOMEN00012000200002502500003795 123456TIE MEN 00ABC000340003500900001099 212121JEANS BOY 0004500023000XX01500001995 234567BLOUSE WOMEN00012000200002002000002499 345678DRESS GIRLS00056000000000001500001799 454545SLACKS MENS XXXXXXXXXXXXXXXXXXXXXXXXXX 567899 ABCDEFSHIRT BOYS 00001ABCDE000040003400032 888888JUMPER GIRLS00012000140002301500001895
Question #3: Looking at the data above and at the program, which of the following is the correct output (EDITGOOD.DAT).
Output #1: |
121212SKIRT WOMEN00012000200002502500003795 212121JEANS BOY 0004500023000XX01500001995 234567BLOUSE WOMEN00012000200002002000002499 888888JUMPER GIRLS00012000140002301500001895 |
Output #2: |
121212SKIRT WOMEN00012000200002502500003795 888888JUMPER GIRLS00012000140002301500001895 |
Output #3: |
121212SKIRT WOMEN00012000200002502500003795 234567BLOUSE WOMEN00012000200002002000002499 888888JUMPER GIRLS00012000140002301500001895 |
Question #4: Looking at the data above and at the program, which of the following is the correct output (EDITERR.DAT).
Output #1: |
123456 00ABC ON HAND NOT NUMERIC 212121 BOY INVALID DEPT NAME 345678 00000 REORDER POINT ZERO 454545 MENS INVALID DEPT NAME 567899 PRICE NOT NUMERIC ABCDEF ABCDEF ITEM NUMBER NOT NUMERIC |
Output #2: |
123456 00ABC ON HAND NOT NUMERIC 212121 BOY INVALID DEPT NAME 212121 000XX REORDER POINT NOT NUMERIC 345678 00000 REORDER POINT ZERO 454545 MENS INVALID DEPT NAME 454545 XXXXX ON HAND NOT NUMERIC 454545 XXXXX ON ORDER NOT NUMERIC 454545 XXXXX REORDER POINT NOT NUMERIC 454545 XXXXX COST NOT NUMERIC 454545 XXXXXX PRICE NOT NUMERIC 567899 ITEM NAME IS BLANK 567899 INVALID DEPT NAME 567899 ON HAND NOT NUMERIC 567899 ON ORDER NOT NUMERIC 567899 REORDER POINT NOT NUMERIC 567899 COST NOT NUMERIC 567899 PRICE NOT NUMERIC ABCDEF ABCDEF ITEM NUMBER NOT NUMERIC ABCDEF ABCDE ON ORDER NOT NUMERIC ABCDF 00032 PRICE NOT NUMERIC |
Output #3: |
123456 00ABC ON HAND NOT NUMERIC 212121 BOY INVALID DEPT NAME 212121 000XX REORDER POINT NOT NUMERIC 345678 00000 REORDER POINT ZERO 454545 MENS INVALID DEPT NAME 454545 XXXXX ON HAND NOT NUMERIC 454545 XXXXX ON ORDER NOT NUMERIC 454545 XXXXX REORDER POINT NOT NUMERIC 454545 XXXXX COST NOT NUMERIC 454545 XXXXXX PRICE NOT NUMERIC 567899 ITEM NAME IS BLANK 567899 INVALID DEPT NAME ABCDEF ABCDEF ITEM NUMBER NOT NUMERIC ABCDEF ABCDE ON ORDER NOT NUMERIC ABCDEF 00032 PRICE NOT NUMERIC |
Question #5: There are multiple ways to code programs. Circle the correct code and explain the problems with the incorrect code.
Way #1: |
IF RE-ORDER-PT NOT NUMERIC MOVE RDF-RE-ORDER-PT TO DATA-IN-ERROR MOVE "REORDER POINT NOT NUMERIC" TO MSG-PR PERFORM U-100-WRITE-ERROR ELSE IF RE-ORDER-PT = 0 MOVE RE-ORDER-PT TO DATA-IN-ERROR MOVE "REORDER POINT ZERO" TO MSG-PR PERFORM U-100-WRITE-ERROR END-IF END-IF |
Way #2: |
IF RE-ORDER-PT NOT NUMERIC MOVE RDF-RE-ORDER-PT TO DATA-IN-ERROR MOVE "REORDER POINT NOT NUMERIC" TO MSG-PR PERFORM U-100-WRITE-ERROR ELSE IF RE-ORDER-PT = 0 MOVE RE-ORDER-PT TO DATA-IN-ERROR MOVE "REORDER POINT ZERO" TO MSG-PR PERFORM U-100-WRITE-ERROR. |
Way #3: |
IF RE-ORDER-PT NOT NUMERIC MOVE RE-ORDER-PT TO DATA-IN-ERROR MOVE "REORDER POINT NOT NUMERIC" TO MSG-PR PERFORM U-100-WRITE-ERROR ELSE IF RE-ORDER-PT = 0 MOVE RE-ORDER-PT TO DATA-IN-ERROR MOVE "REORDER POINT ZERO" TO MSG-PR PERFORM U-100-WRITE-ERROR. |
Way #4: |
IF RE-ORDER-PT NOT NUMERIC OR RE-ORDER-PT = 0 MOVE RE-ORDER-PT TO DATA-IN-ERROR MOVE "INVALID REORDER POINT" TO MSG-PR PERFORM U-100-WRITE-ERROR. |