Q:

Java Program to calculate electricity bill

belongs to collection: Simple Formula Based Java Programs

0

Java Program to calculate electricity bill

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

In this demo I have used NetBeans IDE 8.2 for debugging purpose. But you can use any java programming language compiler as per your availability..

import java.util.*;
class ComputeElectricityBill 
{ 
public static void main(String args[]) 
{   
    int units=280;
 
    double billpay=0;
 
    if(units<100)
    {
    billpay=units*1.20;
    }
    else if(units<300)
           {
       billpay=100*1.20+(units-100)*2;
           }
           else if(units>300)
           {
        billpay=100*1.20+200*2+(units-300)*3;
           }
       
    System.out.println("Bill to pay : " + billpay); 
     } 
}

Result:

Bill to pay : 480.0

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Java Program To Calculate CGPA Percentage... >>
<< Java Program to find factorial of number...