Program for electricity bill, COBOL Programming


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.


    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.


    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 efile at end go to close-para.

    go to c1  c2  c3 c4 depending on ccode.


    compute amt = units * 0.50

    go to m-para.  


    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.    


  if (units < 5000)

  compute amt =  units * 0.30

    go to m-para


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

    go to m-para.  


  compute amt = units * 0.30.


  move amt to e-amt.

  move ccode to e-ccode.

  move units to e-units.

  display head-3.

  go to read-para.


  display head-1.

  close efile.

  stop run.


    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
File- Section &Working-Storage Section: a) FILE SECTION: The FILE SECTION includes the explanation of all data items that must be read from or written onto some external

CONDITION - COBOL Programming: The condition is an entity which at one point of time can have only one of the two values - true or false. As we already know that, the IF verb

COBOL Words: The COBOL word can be formed by using the characters as shown below: 0-9 A-Z (a-z) - (hyphen) The rules below should be hold in forming the COBOL words.

Illustration of if- else statement: IF OK-BALANCE NEXT SENTENCE ELSE MOVE 2 BALANCE-CODE In this illustration, the OK-BALANCE is a condition name. No action is specific if

PROGRAM TO DEMONSTRATE SORT VERB: The file for which a record having 2 fields, viz., Account Number and Name is already available. Sort the file based on the ascending order o

Format for COBOL Programs: The COBOL is a high-level language. Therefore, a COBOL program can be executed on a computer for which a COBOL compiler exists. The compiler transla

INDEXED TABLES: The OCCURS clause that is used to define tables can optionally have an INDEXED phrase. This phrase involves the names of data items which are to be used as sub

PROGRAM FOR INDEXED SEQUENTIAL FILE CREATION (RANDOM MODE): We have to write a program to create an Indexed Sequential File in random mode for Student particulars. Suppose jus

PROGRAM FOR SIMPLE PERFORM: We have to write a program to elaborate simple PERFORM statement Identification division. Program- id.  Perf1. Environment division. Da

Example of Nested if statement: Illustration: Consider the following sentence The nested IF sentence holds two IFs and one ELSE. The IF-ELSE couple has been marke