-1

会社とその情報で構成されるファイルを読み込むプログラムを作成しています。格付けが 3.5 よりも低い企業を除外し、最高の見積もりと最低の見積もりを表示してから、企業の平均を表示します。私はCobolを初めて使用するので、最高、最低、平均を見つける方法がわかりません。モジュール 2012 で動作するものをコーディングして最高値を見つけましたが、プログラムを実行しても情報が表示されません。これについての助けをいただければ幸いです。ありがとうございました

   IDENTIFICATION DIVISION.
   PROGRAM-ID. MOVING-QUOTES.



   ENVIRONMENT DIVISION. 
   INPUT-OUTPUT SECTION.
   FILE-CONTROL.

       SELECT MOVING-QUOTES-FILE ASSIGN TO 'Moving-Quotes.txt'
            ORGANIZATION IS LINE SEQUENTIAL.
       SELECT MOVING-QUOTES-RESULTS-FILE ASSIGN TO "MOVING.TXT"
            ORGANIZATION IS LINE SEQUENTIAL. 

   DATA DIVISION.
   FILE SECTION.
   FD MOVING-QUOTES-FILE.
   01 FS-MOVING-QUOTES-RECORD             PIC X(45).

   FD MOVING-QUOTES-RESULTS-FILE.
   01 MOVING-QUOTES-RESULTS-RECORD        PIC X(80).

   WORKING-STORAGE SECTION.

   01 WS-MOVING-QUOTES-RECORD.
       05 FILLER                           PIC X(2).
       05 MQR-COMPANY-NAME                 PIC X(15).
       05 FILLER                           PIC X(1).
       05 MQR-COMPANY-PHONE                PIC X(13).
       05 FILLER                           PIC X(1).
       05 MQR-MOVING-QUOTE                 PIC 999V99.
       05 FILLER                           PIC X(1).
       05 MQR-NUMBER-ITEMS                 PIC 999.
       05 FILLER                           PIC X(1).
       05 MQR-RATING                       PIC 9V9.

   01 PRT-MOVING-QUOTES-FILE.
       05 FILLER                           PIC X(2).
       05 PRT-MQR-COMPANY-NAME             PIC X(15).
       05 FILLER                           PIC X(1) VALUE SPACES.
       05 PRT-MQR-COMPANY-PHONE            PIC X(13).
       05 FILLER                           PIC X(5).
       05 PRT-MQR-MOVING-QUOTE             PIC $zz99.99.
       05 FILLER                           PIC X(7).
       05 PRT-MQR-NUMBER-ITEMS             PIC 9(3).
       05 FILLER                           PIC X(15).
       05 PRT-MQR-RATING                   PIC 9.9. 

   01 PAGE-TITLE.
       05                  PIC X(22) VALUE SPACES.
       05                  PIC X(40) VALUE  'MOVING COMPANY QUOTES'.
       05                  PIC X(18) VALUE SPACES.
       05 PRT-PAGE-NUM     PIC Z9.

   01 QUOTE-HEADING-1.
       05                               PIC X(7)  VALUE SPACES.
       05                               PIC X(7)  VALUE 'COMPANY'.
       05                               PIC X(9) VALUE SPACES.
       05                               PIC X(5)  VALUE 'PHONE'.
       05                               PIC X(21) VALUE SPACES.
       05                               PIC X(9)  VALUE 'NUMBER OF'.
       05                               PIC X(11) VALUE SPACES.
       05                               PIC X(4)  VALUE 'YELP'.
       05                               PIC X(7). 

   01 QUOTE-HEADING-2.
       05                                  PIC X(8).
       05                                  PIC X(4)  VALUE 'NAME'. 
       05                                  PIC X(11) VALUE SPACES.
       05                                  PIC X(6)  VALUE 'NUMBER'.
       05                                  PIC X(9)  VALUE SPACES.
       05                                  PIC X(5)  VALUE 'QUOTE'.
       05                                  PIC X(7)  VALUE SPACES.
       05                                  PIC X(5)  VALUE 'ITEMS'.
       05                                  PIC X(13) VALUE SPACES.
       05                                  PIC X(6)  VALUE 'RATING'.
       05                                  PIC X(2)  VALUE SPACES.
   01 QUOTE-HEADING-3.          
       05                                  PIC X(6)  VALUE SPACES.
       05                                  PIC X(9)  VALUE  ALL '-'.
       05                                  PIC X(7)  VALUE SPACES.
       05                                  PIC X(8)  VALUE  ALL '-'.
       05                                  PIC X(7)  VALUE SPACES.
       05                                  PIC X(7)  VALUE  ALL '-'.
       05                                  PIC X(5)  VALUE SPACES.
       05                                  PIC X(11) VALUE  ALL '-'.
       05                                  PIC X(7)  VALUE SPACES.
       05                                  PIC X(8)  VALUE  ALL '-'.



   01 WS-SWITCHES-AND-COUNTERS.
       05 WS-EOF                         PIC X       VALUE 'F'.
       05 NUMBER-OF-PAGES                PIC S9(4)   COMP  VALUE 0.
       05 NUMBER-OF-LINES-USED           PIC S9(4)   COMP VALUE 0.
       05 WS-HI-BID                      PIC 999V99 VALUE 0.
       05 WS-LO-BID                      PIC 999V99 VALUE 999.99. 
       05 WS-TOTAL-BID-SUM               PIC 999V99 VALUE 0. 
       05 WS-NUMBER-OF-RECORDS           PIC 9(4)    VALUE 4.
       05 WS-AVERAGE                     PIC 999V99. 

   01 HI-COMPANY-INFO.
       05 FILLER                           PIC X(6) VALUE SPACES.
       05 SAV-HI-MQR-COMPANY-NAME          PIC X(15).
       05 FILLER                           PIC X(2) VALUE SPACES.
       05 SAV-HI-MQR-COMPANY-PHONE         PIC X(13).
       05 FILLER                           PIC X(2) VALUE SPACES.
       05 SAV-HI-MQR-QUOTE                 PIC $ZZ99.99.

   01 LO-COMPANY-INFO.
       05 FILLER                           PIC X(5) VALUE SPACES. 
       05 SAV-LO-MQR-COMPANY-NAME          PIC X(15).
       05 FILLER                           PIC X(2) VALUE SPACES.
       05 SAV-LO-MQR-COMPANY-PHONE         PIC X(13).
       05 FILLER                           PIC X(2) VALUE SPACES. 
       05 SAV-LO-MQR-QUOTE                 PIC $ZZ99.99.

   01 AVG-INFO.
       05                                  PIC X(6) VALUE SPACES.
       05 SAV-AVG                          PIC $ZZ99.99. 

   01 HI-INFO-HD1. 
       05                                  PIC X(8).
       05                                  PIC X(7) VALUE 'HIGH'.
       05                                  PIC X(8).
       05                                  PIC X(5) VALUE 'PHONE'.
       05                                  PIC X(52).

   01 HI-INFO-HD2.
       05                                  PIC X(6).
       05                                  PIC X(7) VALUE 'COMPANY'.
       05                                  PIC X(10).
       05                                  PIC X(6) VALUE 'NUMBER'.
       05                                  PIC X(9).
       05                                  PIC X(5) VALUE 'QUOTE'.
       05                                  PIC X(37).
   01 HI-INFO-HD3.
       05                                  PIC X(5).
       05                                  PIC X(9) VALUE ALL '-'.
       05                                  PIC X(8).
       05                                  PIC X(8) VALUE ALL '-'.
       05                                  PIC X(7).
       05                                  PIC X(7) VALUE ALL '-'.
       05                                  PIC X(36).

   01 LO-INFO-HD1. 
       05                                  PIC X(7).
       05                                  PIC X(3) VALUE 'LOW'.
       05                                  PIC X(13).
       05                                  PIC X(5) VALUE 'PHONE'.
       05                                  PIC X(52). 

   01 LO-INFO-HD2.
       05                                  PIC X(6).
       05                                  PIC X(7) VALUE 'COMPANY'.
       05                                  PIC X(10).
       05                                  PIC X(6) VALUE 'NUMBER'.
       05                                  PIC X(9).
       05                                  PIC X(5) VALUE 'QUOTE'.
       05                                  PIC X(37). 

   01 LO-INFO-HD3.
       05                                  PIC X(5).
       05                                  PIC X(9) VALUE ALL '-'.
       05                                  PIC X(8).
       05                                  PIC X(8) VALUE ALL '-'.
       05                                  PIC X(7).
       05                                  PIC X(7) VALUE ALL '-'.
       05                                  PIC X(36).

   01 AVG-INFO-HD1.
       05                                  PIC X(7).
       05                                  PIC X(7) VALUE 'AVERAGE'.

   01 AVG-INFO-HD2.                       
       05                                  PIC X(6).
       05                                  PIC X(9) VALUE ALL '-'.
       05                                  PIC X(65).

   PROCEDURE DIVISION.
   0000-MAINLINE.
       PERFORM 1000-START-MOVING-QUOTES
       PERFORM 2000-READ-N-PRINT-MQ
            UNTIL WS-EOF = 'T'    
       PERFORM 3000-FINISH-UP
       STOP RUN
       .


  *END OF MAIN BLOCK 

   1000-START-MOVING-QUOTES.
       OPEN INPUT MOVING-QUOTES-FILE
            OUTPUT MOVING-QUOTES-RESULTS-FILE
       PERFORM 8000-READ-MOVING-QUOTES-FILE
       IF WS-EOF NOT = 'T' 
           PERFORM 8020-PRINT-TITLE-AND-HEADINGS.
       .


   8000-READ-MOVING-QUOTES-FILE.
       READ MOVING-QUOTES-FILE 
           AT END MOVE 'T' TO WS-EOF
       end-READ
       MOVE FS-MOVING-QUOTES-RECORD TO 
            WS-MOVING-QUOTES-RECORD 
       .        


   8010-CHECK-LINES.
       ADD 2 TO NUMBER-OF-LINES-USED
       IF NUMBER-OF-LINES-USED > 90 
           PERFORM 8020-PRINT-TITLE-AND-HEADINGS
       .

   8020-PRINT-TITLE-AND-HEADINGS.
       ADD 1 TO NUMBER-OF-PAGES
       MOVE NUMBER-OF-PAGES TO PRT-PAGE-NUM
       MOVE SPACES TO MOVING-QUOTES-RESULTS-RECORD
       MOVE PAGE-TITLE TO MOVING-QUOTES-RESULTS-RECORD 
       WRITE MOVING-QUOTES-RESULTS-RECORD AFTER ADVANCING 3 LINES
       WRITE MOVING-QUOTES-RESULTS-RECORD FROM NUMBER-OF-PAGES
           AFTER ADVANCING 1 LINE          
       WRITE MOVING-QUOTES-RESULTS-RECORD FROM QUOTE-HEADING-1
           AFTER ADVANCING 1 LINE
       WRITE MOVING-QUOTES-RESULTS-RECORD FROM QUOTE-HEADING-2
           AFTER ADVANCING 1 LINE
       WRITE MOVING-QUOTES-RESULTS-RECORD FROM QUOTE-HEADING-3 
           AFTER ADVANCING 1 LINE
       .

   8025-PRINT-HI-HD.
       MOVE SPACES TO MOVING-QUOTES-RESULTS-RECORD
       WRITE MOVING-QUOTES-RESULTS-RECORD FROM HI-INFO-HD1
           AFTER ADVANCING 1 LINE 
       WRITE MOVING-QUOTES-RESULTS-RECORD FROM HI-INFO-HD2
           AFTER ADVANCING 1 LINE
       WRITE MOVING-QUOTES-RESULTS-RECORD FROM HI-INFO-HD3 
           AFTER ADVANCING 1 LINE
       .

   8026-PRINT-LO-HD.
       WRITE MOVING-QUOTES-RESULTS-RECORD FROM LO-INFO-HD1
           AFTER ADVANCING 1 LINE 
       WRITE MOVING-QUOTES-RESULTS-RECORD FROM LO-INFO-HD2
           AFTER ADVANCING 1 LINE 
       WRITE MOVING-QUOTES-RESULTS-RECORD FROM LO-INFO-HD3
           AFTER ADVANCING 1 LINE
       .

   8027-PRINT-AVG-HD.
       WRITE MOVING-QUOTES-RESULTS-RECORD FROM AVG-INFO-HD1
           AFTER ADVANCING 1 LINE 
       WRITE MOVING-QUOTES-RESULTS-RECORD FROM AVG-INFO-HD2
           AFTER ADVANCING 1 LINE
       . 


   2000-READ-N-PRINT-MQ.
  *  PERFORM 8010-CHECK-LINES
       PERFORM 8000-READ-MOVING-QUOTES-FILE
       IF (MQR-RATING >= 3.5) 
           MOVE WS-MOVING-QUOTES-RECORD TO 
           PRT-MOVING-QUOTES-FILE
           PERFORM 2001-PRINT-COMP
           PERFORM 2010-FIND-HI-LO-AVG
       END-IF   


       .

   2001-PRINT-COMP.
       MOVE MQR-COMPANY-NAME TO PRT-MQR-COMPANY-NAME
       MOVE MQR-COMPANY-PHONE TO PRT-MQR-COMPANY-PHONE 
       MOVE MQR-MOVING-QUOTE TO PRT-MQR-MOVING-QUOTE 
       MOVE MQR-NUMBER-ITEMS TO PRT-MQR-NUMBER-ITEMS 
       MOVE MQR-RATING TO PRT-MQR-RATING 
       MOVE PRT-MOVING-QUOTES-FILE TO MOVING-QUOTES-RESULTS-RECORD
       WRITE MOVING-QUOTES-RESULTS-RECORD 
           AFTER ADVANCING 2 LINES
       ADD 1 TO WS-NUMBER-OF-RECORDS  
       .

   2010-FIND-HI-LO-AVG.

       PERFORM 2012-FIND-HI
       PERFORM 2013-STORING-VAL-LO
       PERFORM 2014-FIND-LO
       PERFORM 2015-GET-SUM

       PERFORM 2016-GET-AVERAGE
  *     PERFORM 8000-READ-MOVING-QUOTES-FILE
       .

   2011-STORING-VAL-HI.
       MOVE MQR-MOVING-QUOTE TO WS-HI-BID
       . 

   2012-FIND-HI.
       PERFORM 2011-STORING-VAL-HI   
       IF (MQR-MOVING-QUOTE > WS-HI-BID)
           MOVE MQR-MOVING-QUOTE TO WS-HI-BID
           MOVE MQR-COMPANY-NAME TO SAV-HI-MQR-COMPANY-NAME
           MOVE MQR-COMPANY-PHONE TO SAV-HI-MQR-COMPANY-PHONE 
           MOVE WS-HI-BID TO SAV-HI-MQR-QUOTE
           MOVE HI-COMPANY-INFO TO MOVING-QUOTES-RESULTS-RECORD
           WRITE MOVING-QUOTES-RESULTS-RECORD 
               AFTER ADVANCING 2 LINES
       END-IF
       .               

   2013-STORING-VAL-LO. 
       MOVE MQR-MOVING-QUOTE TO WS-LO-BID
       .       

   2014-FIND-LO. 
       IF (MQR-MOVING-QUOTE < WS-LO-BID) 
       MOVE MQR-MOVING-QUOTE TO WS-LO-BID
       MOVE MQR-COMPANY-NAME TO SAV-LO-MQR-COMPANY-NAME
       MOVE MQR-COMPANY-PHONE TO SAV-LO-MQR-COMPANY-PHONE 
       MOVE MQR-MOVING-QUOTE TO SAV-LO-MQR-QUOTE
       .       

   2015-GET-SUM. 
       ADD MQR-MOVING-QUOTE GIVING WS-TOTAL-BID-SUM
       .

   2016-GET-AVERAGE.
       DIVIDE WS-TOTAL-BID-SUM BY WS-NUMBER-OF-RECORDS  GIVING
              WS-AVERAGE
       MOVE WS-AVERAGE TO SAV-AVG
       .


   3000-FINISH-UP.

       PERFORM 8025-PRINT-HI-HD
       PERFORM 2012-FIND-HI
       PERFORM 3010-PRT-HI
       PERFORM 8026-PRINT-LO-HD
       PERFORM 2014-FIND-LO
       PERFORM 3020-PRT-LO
       PERFORM 8027-PRINT-AVG-HD
       PERFORM 2016-GET-AVERAGE
       PERFORM 3030-PRT-AVG


       CLOSE MOVING-QUOTES-FILE 
             MOVING-QUOTES-RESULTS-FILE
       .

   3010-PRT-HI.
       MOVE HI-COMPANY-INFO TO MOVING-QUOTES-RESULTS-RECORD
       . 

   3020-PRT-LO.
       MOVE LO-COMPANY-INFO TO MOVING-QUOTES-RESULTS-RECORD
       .

   3030-PRT-AVG.
       MOVE SAV-AVG TO MOVING-QUOTES-RESULTS-RECORD
       .
4

1 に答える 1

2

Finding Highest , Lowest and the Average in a Cobol programの更新から取得

2000 年のいくつかの問題 - パフォーマンス 8000 - は手順の最後にあるはずです

現在:

  2000-READ-N-PRINT-MQ.
  *  PERFORM 8010-CHECK-LINES
       PERFORM 8000-READ-MOVING-QUOTES-FILE
       IF (MQR-RATING >= 3.5) 
           MOVE WS-MOVING-QUOTES-RECORD TO 
           PRT-MOVING-QUOTES-FILE
           PERFORM 2001-PRINT-COMP
           PERFORM 2010-FIND-HI-LO-AVG
       END-IF   

次のようにする必要があります。

  2000-READ-N-PRINT-MQ.
  *  PERFORM 8010-CHECK-LINES
       IF (MQR-RATING >= 3.5) 
           MOVE WS-MOVING-QUOTES-RECORD TO 
           PRT-MOVING-QUOTES-FILE
           PERFORM 2001-PRINT-COMP
           PERFORM 2010-FIND-HI-LO-AVG
       END-IF   
       PERFORM 8000-READ-MOVING-QUOTES-FILE

また、2012年に-なぜあなたは書き込みを行っているのですか、これは確かに最後に行う必要があります(セクション3000-)。

2012年-、2013年-は意味がありません

2000年、2011年、2012年にあなたがする必要がある

if value-from-input-file > current-high
   move input-file-details    to current-High-details
end-if 
if value-from-input-file < current-low
   move input-file-details    to current-Low-details
end-if 

次に、ハイ/ローの結果を 3000- で書き出します。

高値/低値を適切に初期化することも非常に重要です???


どちらかを試してください

  • 手順の開始時にディスプレイを配置する(+関連する詳細)
  • デバッガーの使用

どちらもプログラムの流れが何であるかを教えてくれます

于 2016-02-25T00:55:44.530 に答える