Resources » Articles/Knowledge Sharing » Computer & Technology

Program to calculate the electricity bill

Updated: Category: Computer & Technology
Author: Member Level: SilverPoints: 5

A java class to calculate and print the electricity bill to be paid by a customer. Assume that the customer pays a rent of Rs. 250.00 . Upto 100 units Rs. 1.50. For the next 100 units Rs. 2.00. For next 50 units Rs. 2.50. Beyond 250 units Rs. 4.00.

public class ElectricityBill
public static void main()throws IOException
BufferedReader br=new BufferedReader (new InputStreamReader (;
System.out.print("Enter Your Name : ");
String nm=br.readLine();

System.out.print("Enter the units consumed : ");
int units=Integer.parseInt(br.readLine());

double charges=0,fbill=0;

else if(units<=200)
else if(units<=250)

//printing the bill
System.out.println("Your Electricity Bill");
System.out.println("Costumers Name : "+nm);
System.out.println("Units Consumed : "+units);
System.out.println("Charges : "+charges);
System.out.println("Rent Charges : 250 Rs.");
System.out.println("Total Bill : "+fbill);

Did you like this resource? Share it with your friends and show your love!

Responses to "Program to calculate the electricity bill"

Post Comment:

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)

    Type the numbers and letters shown on the left.

    Submit Article     Return to Article Index
    Win an apple watch by simply hitting any or all of the action items below! in Techulator Polls & Giveaways on LockerDome
    Awards & Gifts
    Active Members
    TodayLast 7 Daysmore...

    ISC Technologies, Kochi - India. © All Rights Reserved.