Advertisement
Guest User

Untitled

a guest
Oct 25th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 4.07 KB | None | 0 0
  1.  program-id. Program1 as "ConsoleApplication6.Program1".
  2.  
  3.        environment division.
  4.        
  5.        input-output section.
  6.        
  7.        file-control.
  8.            select payroll-list assign to "C:\Users\1531617\Desktop\in.txt"
  9.                      organization is line sequential.
  10.            select payroll-out assign to "C:\Users\1531617\Desktop\out.txt".  
  11.  
  12.        data division.
  13.        
  14.        fd payroll-list.
  15.        01 sales-info.
  16.            05 sp-number        PIC 99.
  17.            05 sp-name          PIC X(20).
  18.            05 amt-sales        PIC 999V99.
  19.            
  20.        fd payroll-out.
  21.        01 print-info.
  22.            05 filler           PIC X(15).
  23.            05 sp-number-out    PIC 99.
  24.            05 filler           PIC X(12).
  25.            05 sp-name-out      PIC X(20).
  26.            05 filler           PIC X(5).
  27.            05 total-sales      PIC ZZZZZ.99.
  28.            05 filler           PIC X(19).
  29.        
  30.        working-storage section.
  31.        
  32.        01 stop-go                  PIC X VALUE "Y".
  33.        
  34.        01 date-in.
  35.            05 curr-year            PIC 9(4).
  36.            05 curr-month           PIC 9(2).
  37.            05 curr-day             PIC 9(2).
  38.            
  39.        01 header-one.
  40.            05 filler               PIC X(30).
  41.            05 header-title         PIC X(32) VALUE "TOTAL SALES FOR EACH SALESPERSON".
  42.            05 filler               PIC X(4).
  43.            05 day-out              PIC 9(2).
  44.            05 filler               PIC X VALUE "/".
  45.            05 month-out            PIC 9(2).
  46.            05 filler               PIC X VALUE "/".
  47.            05 year-out             PIC 9(4).
  48.            
  49.        01 header-two.
  50.            05 filler               PIC X(10).
  51.            05 no-title             PIC X(15) VALUE "SALESPERSON NO.".
  52.            05 filler               PIC X(4).
  53.            05 name-title           PIC X(16) VALUE "SALESPERSON NAME".
  54.            05 filler               PIC X(9).
  55.            05 sales-title          PIC X(11) VALUE "TOTAL SALES".
  56.            
  57.        01 header-three.
  58.            05 filler               PIC X(40).
  59.            05 sales-title2         PIC X(19) VALUE "TOTAL COMPANY SALES".
  60.            05 filler               PIC X(3).
  61.            05 total-comp-sales     PIC 99999999.99.
  62.            
  63.        01  Sales-arr.
  64.            05  salesman OCCURS 20 TIMES.
  65.                10  arr-sp-name     PIC X(20).
  66.                10  arr-sales       PIC 99999V99.
  67.            
  68.        01 counter                  PIC 99.
  69.        
  70.        01 temp-total               PIC 99999999V99.
  71.  
  72.        procedure division.
  73.        
  74.        move function current-date to date-in.
  75.        
  76.        
  77.        100-Main.
  78.        
  79.        move curr-day to day-out
  80.        move curr-month to month-out
  81.        move curr-year to year-out
  82.        
  83.        open input payroll-list
  84.             output payroll-out
  85.            
  86.             perform until stop-go = "N"
  87.                read payroll-list
  88.                at end
  89.                    move 'N' to stop-go
  90.                    perform 300-Printing
  91.                not at end
  92.                    perform 200-Calc
  93.                end-read
  94.            end-perform
  95.            
  96.        close payroll-list
  97.              payroll-out.
  98.              
  99.        stop run.
  100.        
  101.        200-Calc.
  102.        
  103.        move sp-name to arr-sp-name(sp-number)
  104.        add amt-sales to arr-sales(sp-number)
  105.        add amt-sales to temp-total.
  106.        
  107.        300-Printing.
  108.        
  109.        write print-info from header-one
  110.        after advancing 1 line
  111.        write print-info from header-two
  112.        
  113.        perform varying counter from 1 BY 1 until counter >= 21
  114.            move spaces to print-info
  115.            move counter to sp-number-out
  116.            move arr-sp-name(counter) to sp-name-out
  117.            move arr-sales(counter) to total-sales
  118.            move temp-total to total-comp-sales
  119.            write print-info after advancing 1 line
  120.        end-perform
  121.        
  122.         move total-comp-sales to total-comp-sales
  123.         write print-info from header-three.
  124.        
  125.        end program Program1.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement