Electricity Bill Calculation Based on Units Consumed

Explanation:

  1. Input:
    • The program prompts the user to enter the number of electricity units consumed.
  2. Switch Statement:
    • The switch statement checks the number of units consumed divided by 100 (units / 100).
    • Each case handles a different range of unit consumption:
      • case 0: For 0-99 units, the rate is $1.50 per unit.
      • case 1: For 100-199 units, the first 100 units are billed at $1.50 per unit, and the next 100 units at $2.00 per unit.
      • case 2: For 200-299 units, the first 100 units are billed at $1.50 per unit, the next 100 units at $2.00 per unit, and the next 100 units at $3.00 per unit.
      • case 3: For 300-399 units, the first 100 units are billed at $1.50 per unit, the next 100 units at $2.00 per unit, the next 100 units at $3.00 per unit, and the next 100 units at $4.00 per unit.
      • default: For 400 or more units, any units above 400 are billed at $5.00 per unit in addition to the previous tiers.
  3. Output:
    • The program calculates the bill amount based on the units consumed and prints the total bill.

Example Outputs:

Example 1: 50 Units Consumed

Input:

  • Units Consumed: 50

Output:

Example 2: 150 Units Consumed

Input:

  • Units Consumed: 150

Output:

Example 3: 350 Units Consumed

Input:

  • Units Consumed: 350

Output:

Example 4: 500 Units Consumed

Input:

  • Units Consumed: 500

Output: