Advertisement
Nick-O-Rama

assignment-1-files

Sep 2nd, 2015
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 1.69 KB | None | 0 0
  1.        identification division.
  2.        program-id. assignment-1-files.
  3.        
  4.        environment division.
  5.        input-output section.
  6.        file-control.   select sales-data assign to
  7.            "C:\temp\sales-data.txt".
  8.                        select com-data assign to "C:\temp\com-data.txt".
  9.        configuration section.
  10.  
  11.        data division.
  12.        fd sales-data.
  13.        01  sales-record.
  14.            05  sales-name                      pic x(20).
  15.            05  sales-amount                    pic 999V999.
  16.        fd com-data.
  17.        01 com-record.
  18.            05                                  pic x(5).
  19.            05  name-out                        pic x(20).
  20.            05                                  pic x(15).
  21.            05  com-out                         pic 9999999.99.
  22.        working-storage section.
  23.        01 end-flag                             pic x(3) value "YES".
  24.        01 final-commission                     pic 99.99.
  25.        procedure division.
  26.        100-main.
  27.            open input sales-data
  28.                output com-data
  29.            perform until end-flag = "NO"
  30.                read sales-data
  31.                    at end
  32.                    move "NO" to end-flag
  33.                    not at end
  34.                        perform 150-calculation
  35.                 end-read
  36.             end-perform.
  37.                close sales-data
  38.                      com-data
  39.            goback.
  40.            
  41.        150-calculation.
  42.            move sales-name to name-out
  43.            multiply sales-amount by 0.12 giving final-commission
  44.            move final-commission to com-out
  45.            write com-record after advancing 1 line.
  46.        end program assignment-1-files.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement