* * A sequential file contains records of consumers of an * electricity board having the following structure: * Consumer Number, * Name of Consumer, * Previous Meter Reading and * Current Meter Reading (give appropriate picture clauses). * * Write a COBOL program to print the Electricity Bill * for each consumer in a neat format according to the * following slab: * * Consumption Rate/Unit(in Rs.) * < 50 @ 1.00 * 50 - 100 @ 1.25 * > 100 @ 1.50 * IDENTIFICATION DIVISION. PROGRAM-ID. ELECTRICITY-BILL. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. OBJECT-COMPUTER. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT ELE-FILE ASSIGN TO DISK ORGANIZATION IS LINE SEQUENTIAL. DATA DIVISION. FILE SECTION. FD ELE-FILE LABEL RECORDS ARE STANDARD VALUE OF FILE-ID IS "ELE.DAT" DATA RECORD IS ELE-REC. 01 ELE-REC. 02 CNO PIC 9(4). 02 NAME PIC X(20). 02 PRE-READ PIC 9(6). 02 CUR-READ PIC 9(6). WORKING-STORAGE SECTION. 01 CONSUM PIC 9(4). 01 E-CONSUM PIC Z(3)9. 01 E-CNO PIC Z(3)9. 01 E-PRE-READ PIC Z(5)9. 01 E-CUR-READ PIC Z(5)9. 01 BILL-AMT PIC Z(5).99. 01 PAUSE PIC X. PROCEDURE DIVISION. OPEN-PARA. OPEN INPUT ELE-FILE. PROCESS-PARA. DISPLAY (01 01) ERASE. READ ELE-FILE RECORD AT END GO TO CLOSE-PARA. COMPUTE CONSUM = CUR-READ - PRE-READ. IF CONSUM > 100 COMPUTE BILL-AMT = CONSUM * 1.50 ELSE IF CONSUM > 50 COMPUTE BILL-AMT = CONSUM * 1.25 ELSE COMPUTE BILL-AMT = CONSUM * 1.00. PERFORM DISPLAY-PARA. ACCEPT PAUSE. GO TO PROCESS-PARA. CLOSE-PARA. CLOSE ELE-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. DISPLAY "-----------------------------------------------". DISPLAY " Electricity Bill ". DISPLAY "-----------------------------------------------". DISPLAY " Consumer No.: " E-CNO. DISPLAY " Name : " NAME. DISPLAY " ". DISPLAY " ----------------------------------". DISPLAY " Current Reading : " E-CUR-READ. DISPLAY " Previous Reading : " E-PRE-READ. DISPLAY " ". DISPLAY " Consumption : " E-CONSUM. DISPLAY " ----------------------------------". DISPLAY " Bill Amount : " BILL-AMT. DISPLAY "===============================================".
A sequential file contains records of consumers of an electricity board having the following structure: Consumer Number, Name of Consumer, Previous Meter Reading and Current Meter Reading(give appropriate picture clauses). Write a COBOL program to print the Electricity Bill for each consumer in a neat format .
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment