identification division. program-id. assignment2. environment division. input-output section. file-control. select file-in assign to disk "h:data2.txt" organization is line sequential. select file-out assign to printer, "con". data division. file section. fd file-in label records are standard. 01 record-in. 05 desc-in pic x(14). 05 unit-in pic 999v999. 05 cargo-in pic x(3). 05 price-in pic 99v99. 05 qty-in pic 99999. fd file-out label records are omitted. 01 record-out pic x(80). working-storage section. 01 more-records pic x value 'y'. 01 total-cost pic 99999v99. 01 line1-out. 05 filler pic x(30) value spaces. 05 filler pic x(6) value 'output'. 05 filler pic x(30) value spaces. 01 line2-out. 05 filler pic x(6) value spaces. 05 filler pic x(10) value 'Ship Name'. 05 filler pic x(6) value spaces. 05 filler pic x(5) value 'Units'. 05 filler pic x(6) value spaces. 05 filler pic x(5) value 'Cargo'. 05 filler pic x(6) value spaces. 05 filler pic x(14) value 'Units Price'. 05 filler pic x(6) value spaces. 05 filler pic x(12) value 'Cargo Value'. 01 print-line-out. 05 filler pic x(10) value spaces. 05 desc-out pic x(14). 05 filler pic x(3). 05 cargo-out pic x(14). 05 filler pic x(10) value spaces. 05 price-out pic $z,z99.99. 05 filler pic x(8) value spaces. 05 unit-out pic 999v999. 05 filler pic x(8) value spaces. 05 qty-out pic 9999. 05 filler pic x(10) value spaces. 05 total-cost-out pic $zzz,999.99. 05 filler pic x(13) value spaces. procedure division. 100-main. perform 300-open. perform 400-headings. read file-in at end move 'n' to more-records. perform 200-process until more-records = 'n'. perform 500-close. stop run. 200-process. compute total-cost = price-in * qty-in. perform 600-move. write record-out from print-line-out after advancing 1 line. read file-in at end move 'n' to more-records. 300-open. open input file-in. open output file-out. 400-headings. write record-out from line1-out after advancing 5 lines. write record-out from line2-out after advancing 2 lines. write record-out from print-line-out after advancing 2 lines. 500-close. close file-in. close file-out. 600-move. move desc-in to desc-out. move unit-in to unit-out. move cargo-in to cargo-out. move price-in to price-out. move qty-in to qty-out. move total-cost to total-cost-out.
And this is the contents of Data2:
Quote
IRONSIDE 150500ORE 07550
DALSOHN 064400WHEAT 00980
BALOCHSIDE 330000COPPER 00145
SANTA MARIA 175000OATS 00326
HIGHLAND 180000ALUMINUM11050
I should be getting this output:
Quote
Name Price Value
Bluenose Oil 240,000 88.50 $21,240,000.00
Balochside Ore 150,500 75.50 $ 3,837,750.00
What am I doing wrong? Thanks

New Topic/Question
Reply




MultiQuote




|