Code:
import java.util.*;class ElectricityBill
{
public static void main(String []args)
{
int consumer_no,unit;
double amount;
Scanner in=new Scanner(System.in);
System.out.println("Enter your consumer no.: ");
consumer_no=in.nextInt();
System.out.println("Enter no. of units used: ");
unit=in.nextInt();
if (unit<=50)
{
amount=1.5*unit;
System.out.println("Amount to be paid: "+amount);
}
else if (unit>50 && unit<100)
{
amount=2*unit;
System.out.println("Amount to be paid: "+amount);
}
else if (unit>=100 && unit<200)
{
amount=2.8*unit;
System.out.println("Amount to be paid: "+amount);
}
else if (unit>=200 && unit<300)
{
amount=3.5*unit;
System.out.println("Amount to be paid: "+amount);
}
else if (unit>=300)
{
amount=4.5*unit;
System.out.println("Amount to be paid: "+amount);
}
else
{
System.out.println("Cannot calculate the Electricity Bill");
}
}
}
No comments:
Post a Comment