Advertisement
Nick-O-Rama

assignment-4-if

Sep 10th, 2015
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 2.20 KB | None | 0 0
  1.        identification division.
  2.        program-id. assignment-4-if.
  3.  
  4.        environment division.
  5.        input-output section.
  6.        file-control.  select vehicle-data assign to
  7.                                            "C:\temp\vehicle-data.txt"
  8.                                            organization is line
  9.                                            sequential.                  
  10.                       select output-data assign to
  11.                                            "C:\temp\output-data.txt".
  12.        configuration section.
  13.  
  14.        data division.
  15.        fd vehicle-data.
  16.        01 vehicle-record.
  17.            05 vin                              pic x(17).
  18.            05 make                             pic x(13).
  19.            05 v-type                           pic x(5).
  20.            05 year                             pic 9(4).
  21.        fd output-data.
  22.        01 output-record.
  23.            05 vin-out                          pic x(17).
  24.            05 filler                           pic x(1).
  25.            05 make-out                         pic x(13).
  26.            05 filler                           pic x(1)
  27.            05 type-out                         pic x(5).
  28.            05 filler                           pic x(1).
  29.            05 year-out                         pic 9(4).
  30.        working-storage section.
  31.        01 end-flag                             pic x(3) value "YES".
  32.        procedure division.
  33.        100-main.
  34.            open input vehicle-data
  35.                 output output-data
  36.                 perform until end-flag = "NO"
  37.                    read vehicle-data
  38.                        at end move "NO" to end-flag
  39.                        not at end perform 150-check-year
  40.                    end-read
  41.                end-perform
  42.                    close vehicle-data
  43.                          output-data
  44.            goback.
  45.        150-check-year.
  46.            move spaces to output-record
  47.            if year < 2010
  48.                move vin to vin-out
  49.                move make to make-out
  50.                move v-type to type-out
  51.                move year to year-out
  52.                write output-record after advancing 1 line
  53.            end-if.
  54.        end program assignment-4-if.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement