Computer Science, asked by vaishnavi635, 6 months ago

An electricity board charges the bill depending on the number of units consumed as follows: units consumed: first 100 units=₹5.5per unit, next 200 units = ₹ 6 per unit, above 300 units=₹ 7 per unit.

Write a program to input number of units consumed, calculate and print total bill. Assume that a metre rent of ₹500 is paid by every customer​

Answers

Answered by Anonymous
8

import java.util.Scanner;

class bill {

   public static void main(String[] args) {

       Print("Enter units consumed in kWh: \n");

       Scanner getInput = new Scanner(System.in);

       Print(Calculate_Bill(getInput.nextDouble()));

       getInput.close();

   }

   public static double Calculate_Bill(double kWh) {

       double bill;

       if (kWh <= 100) {

           bill = kWh * 5.5d;

       } else if (kWh >= 100 && kWh <= 200) {

           bill = kWh * 6.0d;

       } else {

           bill = kWh * 7.0d;

       }

       return bill;

   }

   public static void Print(Object _object_) {

       System.out.print(_object_);

   }

}

Answered by keyboardavro
4

Answer:

Explanation:

import java.util.Scanner;

class bill {

  public static void main(String[] args) {

      Print("Enter units consumed in kWh: \n");

      Scanner getInput = new Scanner(System.in);

      Print(Calculate_Bill(getInput.nextDouble()));

      getInput.close();

  }

  public static double Calculate_Bill(double kWh) {

      double bill;

      if (kWh <= 100) {

          bill = kWh * 5.5d;

      } else if (kWh >= 100 && kWh <= 200) {

          bill = kWh * 6.0d;

      } else {

          bill = kWh * 7.0d;

      }

      return bill;

  }

  public static void Print(Object _object_) {

      System.out.print(_object_);

  }

}

Similar questions