program for electricity billan electricity


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.   

 

Request for Solution File

Ask an Expert for Answer!!
COBOL Programming: program for electricity billan electricity
Reference No:- TGS0174683

Expected delivery within 24 Hours