A sequential file contains records of consumers of a Telecom Services having the following structure: Consumer Number, Consumer Name, Name of Exchange, Previous Meter Reading and Current Meter Reading(Give appropriate picture clauses). Write a COBOL program to print Telephone Bill for each consumer in a neat format


      *
      *   A sequential file contains records of consumers of a
      *   Telecom Services having the following structure:
      *   Consumer Number,
      *   Consumer Name,
      *   Name of Exchange,
      *   Previous Meter Reading and
      *   Current Meter Reading (Give appropriate picture clauses).
      *
      *   Write a COBOL program to print Telephone Bill
      *   for each consumer in a neat format according to the
      *   following slab:
      *
      *   Slab   Consumption   Rate/Unit(in Rs.)   Telehpone Rent
      *
      *    I      First 250        @ 0.80             Rs. 250
      *    II     Next 600         @ 1.00             Rs. 300
      *    III    Balance          @ 1.20             Rs. 500
      *
       IDENTIFICATION DIVISION.
       PROGRAM-ID. TELE-BILL.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER.
       OBJECT-COMPUTER.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT TELE-FILE ASSIGN TO DISK
           ORGANIZATION IS LINE SEQUENTIAL.
       DATA DIVISION.
       FILE SECTION.
       FD  TELE-FILE
           LABEL RECORDS ARE STANDARD
           VALUE OF FILE-ID IS "TELE.DAT"
           DATA RECORD IS TELE-REC.
       01  TELE-REC.
           02 CNO      PIC 9(4).
           02 NAME     PIC X(20).
           02 EXC      PIC X(15).
           02 PRE-READ PIC 9(6).
           02 CUR-READ PIC 9(6).
       WORKING-STORAGE SECTION.
       01  CONSUM      PIC 9(6).
       01  E-CONSUM    PIC Z(5)9.
       01  E-CNO       PIC ZZ9.
       01  E-PRE-READ  PIC Z(5)9.
       01  E-CUR-READ  PIC Z(5)9.
       01  RENT        PIC 9(5).
       01  E-RENT      PIC Z(4)9.
       01  CALL-CHARGE PIC 9(5)V99.
       01  E-CC        PIC Z(4)9.99.
       01  BILL-AMT    PIC Z(5).99.
       01  PAUSE       PIC X.
       PROCEDURE DIVISION.
       OPEN-PARA.
           OPEN INPUT TELE-FILE.
       PROCESS-PARA.
           DISPLAY (01 01) ERASE.
           READ TELE-FILE RECORD AT END GO TO CLOSE-PARA.
           COMPUTE CONSUM = CUR-READ - PRE-READ.
           IF CONSUM > 850
              MOVE 500 TO RENT
              COMPUTE CALL-CHARGE = 800 + (CONSUM - 850) * 1.20
           ELSE
              IF CONSUM > 250
                 MOVE 300 TO RENT
                 COMPUTE CALL-CHARGE = 200 + (CONSUM - 250) * 1.00
              ELSE
                 MOVE 250 TO RENT
                 COMPUTE CALL-CHARGE = CONSUM * 0.80.
           MOVE CALL-CHARGE TO E-CC.
           COMPUTE BILL-AMT = RENT + CALL-CHARGE.
           PERFORM DISPLAY-PARA.
           ACCEPT PAUSE.
           GO TO PROCESS-PARA.
       CLOSE-PARA.
           CLOSE TELE-FILE.
           STOP RUN.
       DISPLAY-PARA.
           MOVE CNO TO E-CNO.
           MOVE PRE-READ TO E-PRE-READ.
           MOVE CUR-READ TO E-CUR-READ.
           MOVE CONSUM TO E-CONSUM.
           MOVE RENT TO E-RENT.
           DISPLAY "-----------------------------------------------".
           DISPLAY "               Telephone Bill ".
           DISPLAY "-----------------------------------------------".
           DISPLAY "          Consumer No : " E-CNO.
           DISPLAY "                 Name : " NAME.
           DISPLAY "        Exchange Name : " EXC.
           DISPLAY " ".
           DISPLAY "     ------------------------------------".
           DISPLAY "      Current Reading : " E-CUR-READ.
           DISPLAY "     Previous Reading : " E-PRE-READ.
           DISPLAY "     ------------------------------------".
           DISPLAY "          Consumption : " E-CONSUM.
           DISPLAY " ".
           DISPLAY "                 Rent : Rs. " E-RENT.
           DISPLAY "         Call Charges : Rs. " E-CC.
           DISPLAY "     ------------------------------------".
           DISPLAY "          Bill Amount : Rs. " BILL-AMT.
           DISPLAY "===============================================".


No comments:

Post a comment