1.

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.​

Answer»

: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);    }}



Discussion

No Comment Found