Write a program to input the number of units consumed. Calculate the Electricity bill according the given rates.

Units consumed       Rate

less than 100     80 paisa/unit

For next 200      1 Rs/-

For more than 300   2.50 Rs/-

Print the amount to be paid.

import java.io.*;
class units
{
    public static void main()throws IOException
    {
BufferedReaderbr=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the units consumed");
        double unit=Double.parseDouble(br.readLine());
        double amount=0.0;
        if(unit<=100)
        {
            amount=unit*80/100;
        }
        else if((unit>100)&&(unit<=300))
        {
             amount=80+(unit-100)*1;
        }
        else
        {
            amount=80+(200*1)+(unit-300)*2.50;
        }
System.out.println("The amount of money to be paid is "+amount+"Rs");
    }
}
Enter the units consumed 30
The amount of money to be paid is 24.0 Rs

LEAVE A REPLY

Please enter your comment!
Please enter your name here