Electricity Bill program
Write a program to input the number of units consumed. Calculate the Electricity bill according the given rates.
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");
}
}<tbody>
Enter the units consumed 30
The amount of money to be paid is 24.0 Rs
</tbody>
Related Posts
Continue learning with these related articles

String Methods in Java for ICSE Class 10: 25 Output Questions with Answers
ICSE Class 10 Computer Applications practice on String class methods: length, charAt, indexOf, lastIndexOf, substring, replace, trim, compareTo, equals and more, with 25 board-style output questions and step-by-step answers.

Special Number Programs in Java for ICSE: Armstrong, Spy, Neon, Disarium, Pronic and More
Every special number asked in ICSE Computer Applications – prime, perfect, Armstrong, palindrome, automorphic, neon, spy, Niven, duck, buzz, Disarium, special and pronic numbers – with definitions, examples and one complete Java program that checks them all.

Math Library Methods in Java for ICSE Class 9 (with Outputs)
ICSE Class 9 Computer Applications notes on the Java Math class: sqrt, cbrt, pow, abs, max, min, ceil, floor, round, rint and random, with return types, tricky negative-number outputs and Java expressions for formulas.