# Program to calculate the electricity bill

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.

import java.io.*;
public class ElectricityBill
{
public static void main()throws IOException
{

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

double charges=0,fbill=0;

if(units<=100)
charges=units*1.50;
else if(units<=200)
charges=(100*1.50)+(units-100)*2;
else if(units<=250)
charges=(100*1.50)+(100*2)+(units-200)*2.50;
else
charges=(100*1.50)+(100*2)+(50*2.50)+(units-250)*4;

fbill=charges+250;
System.out.print("\f");
//printing the bill
System.out.println("*********************");
System.out.println();
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);
}
}

## Related Articles

#### Conservation of electricity - the do's and don'ts!

We all use electricity for most of the purposes in our day to day's life. How many of you would think right about the use of electricity? Here in this article, you will find the right ways of using electricity and the ways to conserve electric energy for our future.

#### Fuel Cells-Oxygen -Hydrogen Fuel Cells: An Eco Friendly Approach Towards Producing Electricity

Thermal power plants these days have a high risk of failure, they are also not Eco-friendly and pollute and harm the environment. As an alternative for these thermal power plants which are harmful based on burning of fossil fuels, Fuel cells have been developed which are Eco-friendly and can run continuously

#### Electricity generation from tides

This article describes how electricity generation from tides works. Also some considerations, pros and cons before going in for electricity generation from tides.

#### Electricity usage of various devices–Consumption, Calculation, Costs and Conservation

This article deals with electricity usage of various household devices. It shows ways to calculate the electricity consumption and hence ways to conserve the electricity. It has become extremely important to take measures to conserve electricity.

More articles: Electricity