Computer Science, asked by allstar3, 2 months ago

Wap in Java to accept the total units consumed by the customer and calculate the bill.Assume that a metre into rupees 500 discharge from the customer.​

Attachments:

Answers

Answered by dreamrob
0

Program :

import java.util.*;

public class MyClass

{

   public static void main(String args[])

   {

       Scanner Sc = new Scanner(System.in);

       double Amount , units;

       System.out.print("Enter total units consumed : ");

       units = Sc.nextDouble();

       if(units <= 100)

       {

           Amount = 500 + (units * 0.80);

       }

       else if(units > 100 && units <= 300)

       {

           Amount = 500 + (100 * 0.80) + ((units - 100) * 1);

       }

       else

       {

           Amount = 500 + (100 * 0.80) + (200 * 1) + ((units - 300) * 2.50);

       }

       System.out.print("Bill : " + Amount);

   }

}

Similar questions