Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | IT Developer <?php echo $page_title; ?>
IT Developer

Conditional Constructs in Java

Chapter 8

Conditional Constructs in Java

Class 10 - Logix Kips ICSE Computer Applications with BlueJ


Share with a Friend

Java Program: To Calculate the Electricity Bill using Slab Rates


30. The electricity board charges the bill according to the number of units consumed and the rate as given below:

Units Consumed

Rate Per Unit

First 100 units

80 Paisa per unit

Next 200 units

Rs. 1 per unit

Above 300 units

Rs. 2.50 per unit

Write a program in Java to accept the total units consumed by a customer and calculate the bill. Assume that a meter rent of Rs. 500 is charged from the customer.

import java.util.Scanner;

 

public class ElectricityBill {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

 

        int units;

        double bill = 0;

 

        System.out.print("Enter total units consumed: ");

        units = sc.nextInt();

 

        if (units <= 100) {

            bill = units * 0.80;

        } else if (units <= 300) {

            bill = (100 * 0.80) + ((units - 100) * 1.00);

        } else {

            bill = (100 * 0.80) + (200 * 1.00) + ((units - 300) * 2.50);

        }

 

        // Add meter rent

        bill = bill + 500;

 

        System.out.println("Total Electricity Bill = Rs. " + bill);

    }

}

Output

Sample Run 
Enter total units consumed: 350
Total Electricity Bill = Rs. 905.0

Calculation

  • First 100 units → 100 × 0.80 = 80
  • Next 200 units → 200 × 1.00 = 200
  • Remaining 50 units → 50 × 2.50 = 125
  • Energy charge = 405
  • Meter rent = 500
  • Total Bill = Rs. 905

📝 Explanation

  • Units are taken as input using the Scanner class
  • Slab-wise billing is applied using an if-else ladder
  • Meter rent of Rs. 500 is added at the end
  • The final bill is displayed in rupees