Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask COBOL Expert


Home >> COBOL

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.   

 

COBOL, Programming

  • Category:- COBOL
  • Reference No.:- M9512281

Have any Question?


Related Questions in COBOL

Write a program that will provide a list of their employees

Write a program that will provide a list of their employees with the following information: Field Size Type Additional Information Employee Number 5 Alphanumeric Employee Name 20 Alphanumeric Position Title (PT) 10 Alpha ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As