Revision Programs

Set 8

Electricity Bill: Slab Calculation

1.1. Sequence Construct

  1. Input name of customer, consumer number, previous reading and present reading. Find number of units used, electricity charge and print a bill. The charge is Rs. 2.50 per unit.

2. Conditional Construct: Selection Statement

2.1. if

  1. Input previous reading and present reading. Find the units used, electricity charge and print a bill. If the units is above 40 then the charge is Rs. 2.50 per unit. (For others no charge). Use simple if.

2.2. if else

  1. Input previous reading and present reading. Find the electricity charge and print the bill.
    For the first 40 units the charge is Rs. 2.50 per unit. For remaining units Rs. 4.00 per unit.

2.3. if else if else

  1. Input previous reading and present reading. Find electricity charge and print a bill.
    For the first 40 units the charge is Rs. 2.50 per unit.
    Next 40 units Rs. 4.00 per unit.
    For remaining units Rs. 6.00 per unit.

2.4. Nested if else if else

  1. Input number of units and category. Find electricity charge. The calculation is given below:
    Number of units Domestic (D) (Rs. per unit) Business (B) (Rs. per unit)
    For first 40 units 2.50 3.50
    Next 40 units 4.00 5.00
    Remaining units 6.00 7.00

2.5. if After if else

  1. Input previous reading and present reading. Find electricity charge and print a bill.
    For the first 40 units charge is Rs. 2.50 per unit.
    For remaining units Rs. 4.00 per unit.
    For Electricity Board employees no charge.

2.6. switch case

  1. W a m d p: Input category as choice and units. Find electricity charge. Calculation is given below:
    Number of units Domestic (D) (Rs. per unit) Business (B) (Rs. per unit)
    For first 40 units 2.50 3.50
    Next 40 units 4.00 5.00
    Remaining units 6.00 7.00

3. Iterative Construct (Loop):

3.1. for

  1. Input n subscribers’ names and number of units. Find electricity charge and print a bill for each subscriber. Also find total collection.
    For first 40 units charge is Rs. 2.50 per unit.
    Remaining units Rs. 4.00 per unit.