Write a program to calculate electricity bill in java

Write a program to calculate electricity bill in java. Multiply the wattage of the gadget by the number of hours it is used per day. Multiply by 1000. Subtract your kWh rate from the total. If else is a conditional statement in programming that executes a separate series of statements based on whether an expression is true or false. A common if else sentence might look something like this. If conditional statements have more than one condition, they are called if conditional statements. Only if the first condition is false will the second condition be examined. If the second one is false as well, the program will fall back to other or do nothing.

class Main
{
public static void main(String args[])
{
int unit=500;
double bill=0;
if(unit<100)
{
bill=unit*1.20;
}
else if(unit<300)
{
bill=100*1.20+(unit-100)*2;
}
else if(unit>300)
{
bill=100*1.20+200*2+(unit-300)*3;
}
System.out.println("Electric bill calculator" + bill);
}
}

 

Output:

Electric bill calculator1120.0