2
 IDENTIFICATION DIVISION.
 PROGRAM-ID. MP4-5.
 ENVIRONMENT DIVISION.
 DATA DIVISION.
 WORKING-STORAGE SECTION.

 01 SEAT-DESCRIPTION.
    03 FILLER PIC X(50) VALUE "01   DRIVER".
    03 FILLER PIC X(50) VALUE "02   DRIVER'S ASST".
    03 FILLER PIC X(50) VALUE "03".
    03 FILLER PIC X(50) VALUE "04".
    03 FILLER PIC X(50) VALUE "05".
    03 FILLER PIC X(50) VALUE "06".
    03 FILLER PIC X(50) VALUE "07".
    03 FILLER PIC X(50) VALUE "08".
    03 FILLER PIC X(50) VALUE "09".
    03 FILLER PIC X(50) VALUE "10".
    03 FILLER PIC X(50) VALUE "11".
    03 FILLER PIC X(50) VALUE "12".
    03 FILLER PIC X(50) VALUE "13".
    03 FILLER PIC X(50) VALUE "14".
    03 FILLER PIC X(50) VALUE "15".

 01 MAIN-MENU   PIC X.
   88 RESERVATION VALUE "R".
   88 VIEW-RESERVATION VALUE "V".
   88 CANCEL-RESERVATION VALUE "D".
   88 EXIT-PROC VALUE "E".

 01 DECISION PIC X.
   88 YES VALUE "Y".
   88 NAY VALUE "N".   

 01 SEAT-NUM PIC 9(2).

 01 CUST-NAME PIC X(18).

 01 CUST-CNTCT PIC 9(11).

 01 CHOICE PIC X.

PROCEDURE DIVISION.
MAIN-ROUTINE.

 DISPLAY "        ABC TRANSPORT COMPANY".
 DISPLAY "__________________________________________".
 DISPLAY "     [R] ADD RESERVATION/S ".
 DISPLAY "     [V] VIEW RESERVATION/S ".
 DISPLAY "     [D] CANCEL RESERVATION/S ".
 DISPLAY "     [E] EXIT".
 DISPLAY "         ENTER CHOICE: " WITH NO ADVANCING.

 ACCEPT MAIN-MENU.

 PERFORM I-CHAIN.

I-CHAIN.
 IF RESERVATION
    GO TO RESERVE-PROC
 ELSE IF VIEW-RESERVATION
    GO TO VRESERVE-PROC
 ELSE IF CANCEL-RESERVATION
    GO TO CRESERVE-PROC
 ELSE IF EXIT-PROC
    GO TO END-PGM
 ELSE
    DISPLAY "INVALID OPTION"

 GO TO MAIN-ROUTINE.


RESERVE-PROC.
 DISPLAY "RESERVE SEAT #:   "WITH NO ADVANCING.
 ACCEPT SEAT-NUM.

 IF SEAT-NUM IS NUMERIC
      IF SEAT-NUM >2 AND SEAT-NUM <16
      GO TO CONT-RES
      ELSE
             DISPLAY "INVALID OPTION"
             PERFORM RESERVE-PROC
 ELSE 
    DISPLAY "ENTER A NUMERIC VALUE"
    GO TO RESERVE-PROC.

CONT-RES.
 DISPLAY "CUSTOMER NAME :     "WITH NO ADVANCING.
 ACCEPT CUST-NAME.

 MOVE CUST-NAME TO SEAT-NUM.
 DISPLAY "CUSTOMER CONTACT #: "WITH NO ADVANCING.
 ACCEPT CUST-CNTCT.

 MOVE CUST-CNTCT TO SEAT-NUM.
 GO TO RESER-CONT.

RESER-CONT.
 DISPLAY "RESERVE MORE? [Y/N]? "WITH NO ADVANCING.
 ACCEPT DECISION.
 IF YES
     PERFORM RESERVE-PROC
 ELSE IF NAY
     PERFORM MAIN-ROUTINE
 ELSE
     DISPLAY "INVALID OPTION"
     PERFORM RESER-CONT.

VRESERVE-PROC.
 DISPLAY "        ABC TRANSPORT COMPANY".
 DISPLAY "           RESERVATION LIST".
 DISPLAY "__________________________________________".
 DISPLAY " "SEAT-DESCRIPTION.

CRESERVE-PROC.
 DISPLAY "        ABC TRANSPORT COMPANY".
 DISPLAY "         CANCEL RESERVATION".
 DISPLAY "__________________________________________".

END-PGM.
 STOP RUN.

我知道代码还没有完成,但我可以在如何使用表格方面提供一些帮助,因为我很难显示我想要添加到变量 SEAT-NUM 的内容以及删除字符串 1 的任何提示1会有帮助

4

2 回答 2

2

首先,您需要类似的东西

01 SEAT-DESCRIPTION-REDEF REDEFINES SEAT-DESCRIPTION.
   03 SEAT-NUMBER-DATA OCCURS 15.
      05 SEAT-NUMBER-TEXT   PIC X(02).
      05 FILLER             PIC X(04).
      05 SEAT-FILLED-BY     PIC X(44).

您现在可以分配一个值来SEAT-FILLED-BY(SEAT-NUM)为座位分配一个名称。

目前尚不清楚您在做什么,CUST-CNTCT但进行了一些小调整:

01 SEAT-DESCRIPTION-REDEF REDEFINES SEAT-DESCRIPTION.
   03 SEAT-NUMBER-DATA OCCURS 15.
      05 SEAT-NUMBER-TEXT   PIC X(02).
      05 FILLER             PIC X(04).
      05 SEAT-FILLED-BY     PIC X(32).
      05 FILLER             PIC X(01).
      05 SEAT-CONTACT       PIC X(11).

现在你可以MOVE CUST-CNTCT TO SEAT-CONTACT(SEAT-NUM).,这可能接近你想要做的。

现在有一个关于结构的小广告。

避开去。

从来没有必要使用GO TO。总是

PERFORM paragraphname [UNTIL condition].

在你习惯它之前,这不是一门容易的学科——当你做意大利面条代码的噩梦时,你就会习惯它;GO TO s 到处都是并执行调用递归代码。

如果有人提到PERFORM THROUGH,只需微笑和点头,然后忽略他们要说的一切。他们是邪恶的缩影,因为他们提倡依赖布局的代码。

于 2013-12-10T15:40:06.947 回答
0

我们THROUGH在我们的商店使用,但出于一个目的。我们用一个名称标记每个段落,并在末尾用“-”退出该名称关闭该段落。

然后当我们调用该段落时,我们使用语法调用它

"PERFORM L2-SUB-PARAGRAPH THROUGH L2-SUB-PARAPGRAPH-EXIT.

这使代码更具面向对象的外观,并使段落更加模块化。

或者,如果想遍历一个段落,您可以像这样编写代码:

`PERFORM -L2-LOOPING-PARA' 
     'THROUGH L2-LOOPING-PARA-EXIT'
         'VARYING INDEX1 FROM 1 BY 1.... `
于 2013-12-12T22:15:53.537 回答