Program for electricity bill, COBOL Programming

PROGRAM FOR ELECTRICITY BILL:

An electricity company supplies electricity to 4 types of customers coded 1, 2, 3 & 4.The rate schedule for customers is shown in one table as 

           Customer code            1        2         2        3        3       4

           Consumption             All    Below  1000&  Below  5000&   All  

                                                     1000     above   5000     above

           Rate/unit                   0.50    0.40     0.50     0.30      0.50       0.30

           The customer record is:

              col:1-5   customer no.

              col:6-60  name & address.

              col:61-67 consumption in units.

              col:68    customer code.

 

           Read  a customer record and print a bill using GOTO  DEPENDING 

        ON statement.

 

  identification division.

  program- id.

  environment division.

  input-output section.

  file-control.

    select efile assign to disk

    organization is line sequential.

  data division.

  file section.

  fd  efile

label records are standard

value of file- id is "e.dat".

  01  erec.

    02  ccode  pic 9.

    02  units       pic 9(7).

 

  working-storage section.

  01   ans pic x value space.

  01   head-1 pic x(80) value all '-'.

  01   amt  pic 9(5)v9(2) value 0.

 

  01   head-2.

    02  f pic x(11) value spaces.

    02  f pic x(6) value "CSCODE".

    02  f pic x(11) value spaces.

    02  f pic x(5) value "Units".

    02  f pic x(11) value spaces.

    02  f pic x(10) value "Amount".

    02  f pic x(11) value spaces.

 

  01 head-3.

    02  f pic x(5) value spaces.

    02  e-ccode  pic z.

    02  f pic x(5) value spaces.

    02  e-units pic z(7).

    02  f pic x(10) value spaces.

    02  e-amt  pic z(5).z(2). 

  screen section.

  01  b-screen.

    02 blank screen.

 

  procedure division.

  p-1.

    open extend efile.

    perform g-w-para until ans = 'n' or 'N'.

    close efile.

 

    open input efile.

    display head-1.

    display head-2.

    display head-1.

  read-para.

    read efile at end go to close-para.

    go to c1  c2  c3 c4 depending on ccode.

  c1.

    compute amt = units * 0.50

    go to m-para.  

  c2.

    if ( units < 1000)

    compute amt = units * 0.40

    go to m-para.  

  if (units not < 1000 ) 

        compute amt = (units - 999) * 0.5 + 999 * 0.40

    go to m-para.    

c3.

  if (units < 5000)

  compute amt =  units * 0.30

    go to m-para

  else  

          compute amt = (units - 4999) * 0.5 + 4999 * 0.30

    go to m-para.  

c4.  

  compute amt = units * 0.30.

     m-para.

  move amt to e-amt.

  move ccode to e-ccode.

  move units to e-units.

  display head-3.

  go to read-para.

close-para.

  display head-1.

  close efile.

  stop run.

  g-w-para.

    display b-screen.

    display(3 5) "Cus Code: ".

    accept ccode.

    display (5 5) "Units : ".

    accept units.

    write erec.

    display(10 5) "Continue [y/n] : ".

    accept ans.   

 

Posted Date: 10/18/2012 2:10:08 AM | Location : United States







Related Discussions:- Program for electricity bill, Assignment Help, Ask Question on Program for electricity bill, Get Answer, Expert's Help, Program for electricity bill Discussions

Write discussion on Program for electricity bill
Your posts are moderated
Related Questions
FD Entry for variable-length Records: The RECORDS CONTAINS and BLOCK CONTAINS clause are quite dissimilar in the case of files with variable- length records. The syntax of the

DELETE STATEMENT : The file should be opened in the I-O mode. If the access is SEQUENTIAL, the INVALID KEY phrase must be specified. Rather than, the last input-output state

FILE-CONTROL paragraph for the relative files: The normal format for the SELECT clause for a relative file is as shown below. SELECT  file-name  ASSIGN  TO  implementor-nam

PROGRAM FOR INVENTORY  We have to write a program to update the inventory file. Consider 2 files,viz, invfile an tranfile. Invfile has 3 fields pno,name,qty. Tranfile has 3 fil

INPUT AND OUTPUT PROCEDURE IN SORT STATEMENT: The common format of the SORT statement can write as shown below: The format of the RELEASE statement is as shown be

DELETE STATEMENT: The format of the delete statement is as shown below: DELETE   file-name RECORD   [  ;   INVALID   KEY  imperative-statement  ] Whenever the ACCESS MOD

DISPLAY STATEMENT:   The function of the DISPLAY statement is just opposite to that of the ACCEPT statement. It is used to display the low-volume results on the operator's co

.(Period or Decimal Point) : The period may be used to insert a decimal point and may not come into view more than once. Both the period and V cannot appear in similar picture

PROGRAM FOR MASTER FILE MAINTENANCE: We have to write a program to keep the stu-file for which a record has just 2 fields,viz., rno(Roll Number) and name(Student Name). Give t

IF STATEMENT: The easiest form of the IF statement is  IF condition-1 statement-1 where the condition-1 may be any one from the shown below. When the condition-1