Knowee
Questions
Features
Study Tools

To develop a Java application to generate Electricity bill. Create a class with the following members: Consumer no., consumer name, previous month reading, current month reading, type of EB connection (i.e domestic or commercial). Compute the bill amount using the following tariff. If the type of the EB connection is domestic, calculate the amount to be paid as follows:First 100 units - Rs. 1 per unit101-200 units - Rs. 2.50 per unit201 -500 units - Rs. 4 per unit> 501 units - Rs. 6 per unitIf the type of the EB connection is commercial, calculate the amount to be paid as follows:First 100 units - Rs. 2 per unit101-200 units - Rs. 4.50 per unit201 -500 units - Rs. 6 per unit> 501 units - Rs. 7 per unitSample:InputEnter consumer number 1001Enter Type of connection (D for Domestic or C for Commercial) DEnter consumer name  SachinEnter previous month reading 3000Enter current month reading 4000OutputConsumer number = 1001Consumer name = Sachintype of connection = DOMESTICCurrent Month Reading = 4000.0Previous Month Reading = 3000.0Total units = 1000.0Total bill = RS 6000.0

Question

To develop a Java application to generate Electricity bill. Create a class with the following members: Consumer no., consumer name, previous month reading, current month reading, type of EB connection (i.e domestic or commercial). Compute the bill amount using the following tariff. If the type of the EB connection is domestic, calculate the amount to be paid as follows:First 100 units - Rs. 1 per unit101-200 units - Rs. 2.50 per unit201 -500 units - Rs. 4 per unit> 501 units - Rs. 6 per unitIf the type of the EB connection is commercial, calculate the amount to be paid as follows:First 100 units - Rs. 2 per unit101-200 units - Rs. 4.50 per unit201 -500 units - Rs. 6 per unit> 501 units - Rs. 7 per unitSample:InputEnter consumer number 1001Enter Type of connection (D for Domestic or C for Commercial) DEnter consumer name  SachinEnter previous month reading 3000Enter current month reading 4000OutputConsumer number = 1001Consumer name = Sachintype of connection = DOMESTICCurrent Month Reading = 4000.0Previous Month Reading = 3000.0Total units = 1000.0Total bill = RS 6000.0

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a step-by-step guide on how to develop a Java application to generate an Electricity bill:

  1. First, create a class named ElectricityBill:
public class ElectricityBill {
    private int consumerNo;
    private String consumerName;
    private double previousMonthReading;
    private double currentMonthReading;
    private char typeOfConnection;
    // getters and setters
}
  1. Create a constructor for the class to initialize the variables:
public ElectricityBill(int consumerNo, String consumerName, double previousMonthReading, double currentMonthReading, char typeOfConnection) {
    this.consumerNo = consumerNo;
    this.consumerName = consumerName;
    this.previousMonthReading = previousMonthReading;
    this.currentMonthReading = currentMonthReading;
    this.typeOfConnection = typeOfConnection;
}
  1. Create a method to calculate the bill:
public double calculateBill() {
    double units = currentMonthReading - previousMonthReading;
    double bill = 0;
    if (typeOfConnection == 'D') {
        if (units <= 100) {
            bill = units * 1;
        } else if (units <= 200) {
            bill = 100 + (units - 100) * 2.5;
        } else if (units <= 500) {
            bill = 100 + 100 * 2.5 + (units - 200) * 4;
        } else {
            bill = 100 + 100 * 2.5 + 300 * 4 + (units - 500) * 6;
        }
    } else {
        if (units <= 100) {
            bill = units * 2;
        } else if (units <= 200) {
            bill = 100 * 2 + (units - 100) * 4.5;
        } else if (units <= 500) {
            bill = 100 * 2 + 100 * 4.5 + (units - 200) * 6;
        } else {
            bill = 100 * 2 + 100 * 4.5 + 300 * 6 + (units - 500) * 7;
        }
    }
    return bill;
}
  1. Now, you can create an object of ElectricityBill class, set the values and call the calculateBill() method to get the bill amount.
public static void main(String[] args) {
    ElectricityBill bill = new ElectricityBill(1001, "Sachin", 3000, 4000, 'D');
    double billAmount = bill.calculateBill();
    System.out.println("Consumer number = " + bill.getConsumerNo());
    System.out.println("Consumer name = " + bill.getConsumerName());
    System.out.println("Type of connection = " + (bill.getTypeOfConnection() == 'D' ? "DOMESTIC" : "COMMERCIAL"));
    System.out.println("Current Month Reading = " + bill.getCurrentMonthReading());
    System.out.println("Previous Month Reading = " + bill.getPreviousMonthReading());
    System.out.println("Total units = " + (bill.getCurrentMonthReading() - bill.getPreviousMonthReading()));
    System.out.println("Total bill = RS " + billAmount);
}

This program will output the details of the consumer and the calculated bill amount.

This problem has been solved

Similar Questions

Experiment 1 PROGRAM TO GENERATE ELECTRICITY BILL AIM To develop a Java application to generate Electricity bill. PROCEDURE 1.Create a class with the following members Consumer no., consumer name, previous month reading, current month reading, type of EB connection (i.e domestic or commercial). 2.Compute the bill amount using the following tarif…

Write a program in java to input number of water units consumed.Get the details like consumer name, consumer number, consumer type and the no. of units consumed. If the consumer is “Domestic” compute the total bill amount according to following slab.Below 150 Rs 250151 to 175 Re 1.00 per unit176 to 300 Rs 1.75 per unitAbove 300 Rs 2.25 per unit​If the consumer type is : “Industry” use the following rulesBelow150 Rs 200/=151 to 175 Re 0.75 per unitNext 176 to 300 Rs 1per unitAbove 300 Rs 2 per unit​

Given the number of units consumed by a domestic user in Tamil Nadu, write a program to calculate the electricity bill. The Tamil Nadu electricity bill tariff for domestic user is given belowTamilNadu Electricity BillConsumption upto 500 unitUnits from         To Units                    Unit Cost / KWH     1                      100                                  0    101                   200                               2.25    201                  400                                4.50    401                  500                                6.00Consumption above 500 units     1                     100                                 0    101                   400                             4.50    401                  500                               6    501                   600                              8    601                   800                              9    801                   1000                           10Above 1000 units                                     11 Input Format:Give the number of units consumed:Output Format:Tariff:  Sample Input: 400Sample Output:

Write a program to input the electricity unit consumed and calculate the total electricity bill according to the given conditions: For the first 50 units Rs. 3.50/unit For the next 100 units Rs. 4.50/unit For the next 100 units Rs. 5.20/unit For units above 250 Rs. 6.75/unit An additional surcharge of 20% is added to the bill.Input format :The input consists of the units consumed.Output format :The output prints the final bill amount.Round off the output to two decimal places.Refer to the sample output for formatting specifications.Sample test cases :Input 1 :50Output 1 :210.00Input 2 :150Output 2 :750.00Input 3 :250Output 3 :1374.00Input 4 :300Output 4 :1779.00

Create a class for Electricity for N flats of an apartment. The required details are Flat number, EB meter number, Owner name, Previous month reading (in Units), current month reading (in Units), amount. Amount will be calculating as below:0-100 = Minimum charges ₹100.00101-500 = 2.50 ₹ per unit501-1000 = 5.00 ₹ per unitAbove 1000 =7.50 ₹ per unit                    Write appropriate functions to perform the following:Display the flat number, owner name, previous reading and current reading.Floor will be identified from the first digit of a flat number.  For 1001 – first floor, 2005 – second floor, 5010- Fifth floor. Display the floor wise details with total units and total amount.Input format:Enter the flat No:Enter the flat owner Name:Enter the previous reading:Enter the current reading:Output format:Total Units:Total amount:

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.