Knowee
Questions
Features
Study Tools

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 ₹100101-500 = 2.5 ₹ per unit501-1000 = 5.0 ₹ per unitAbove 1000 =7.5 ₹ 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:

Question

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 ₹100101-500 = 2.5 ₹ per unit501-1000 = 5.0 ₹ per unitAbove 1000 =7.5 ₹ 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:

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

Solution 1

Here is a Python code that creates a class for Electricity for N flats of an apartment and performs the required operations:

class Electricity:
    def __init__(self, flat_no, owner_name, prev_reading, curr_reading):
        self.flat_no = flat_no
        self.owner_name = owner_name
        self.prev_reading = prev_reading
        self.curr_reading = curr_reading
        self.units = self.curr_reading - self.prev_reading
        self.amount = self.calculate_amount()

    def calculate_amount(self):
        if self.units <= 100:
            return 100
        elif self.units <= 500:
            return self.units * 2.5
        elif self.units <= 1000:
            return self.units * 5.0
        else:
            return self.units * 7.5

    def display_details(self):
        print(f"Flat Number: {self.flat_no}")
        print(f"Owner Name: {self.owner_name}")
        print(f"Previous Reading: {self.prev_reading}")
        print(f"Current Reading: {self.curr_reading}")

    def display_floor_details(self):
        floor = int(str(self.flat_no)[0])
        print(f"Floor: {floor}")
        print(f"Total Units: {self.units}")
        print(f"Total Amount: {self.amount}")

# Input
flat_no = int(input("Enter the flat No: "))
owner_name = input("Enter the flat owner Name: ")
prev_reading = int(input("Enter the previous reading: "))
curr_reading = int(input("Enter the current reading: "))

# Create an instance of Electricity
e = Electricity(flat_no, owner_name, prev_reading, curr_reading)

# Display details
e.display_details()

# Display floor details
e.display_floor_details()

This code first creates a class Electricity with the required attributes and methods. The calculate_amount method calculates the amount based on the number of units. The display_details method displays the flat number, owner name, previous reading, and current reading. The display_floor_details method displays the floor number, total units, and total amount.

The input is taken from the user for flat number, owner name, previous reading, and current reading. An instance of the Electricity class is created with these inputs. The details and floor details are then displayed using the respective methods.

This problem has been solved

Solution 2

Here is a Python code that creates a class for Electricity for N flats of an apartment and performs the required operations:

class Electricity:
    def __init__(self, flat_no, owner_name, prev_reading, curr_reading):
        self.flat_no = flat_no
        self.owner_name = owner_name
        self.prev_reading = prev_reading
        self.curr_reading = curr_reading
        self.units = self.curr_reading - self.prev_reading
        self.amount = self.calculate_amount()

    def calculate_amount(self):
        if self.units <= 100:
            return 100
        elif self.units <= 500:
            return self.units * 2.5
        elif self.units <= 1000:
            return self.units * 5.0
        else:
            return self.units * 7.5

    def display_details(self):
        print(f"Flat Number: {self.flat_no}")
        print(f"Owner Name: {self.owner_name}")
        print(f"Previous Reading: {self.prev_reading}")
        print(f"Current Reading: {self.curr_reading}")

    def floor_details(self):
        floor = str(self.flat_no)[0]
        print(f"Floor: {floor}")
        print(f"Total Units: {self.units}")
        print(f"Total Amount: {self.amount}")

# Input
flat_no = int(input("Enter the flat No: "))
owner_name = input("Enter the flat owner Name: ")
prev_reading = int(input("Enter the previous reading: "))
curr_reading = int(input("Enter the current reading: "))

# Create an object of Electricity class
e = Electricity(flat_no, owner_name, prev_reading, curr_reading)

# Display details
e.display_details()

# Display floor details
e.floor_details()

This code first creates a class named Electricity with the required attributes. It also includes a method to calculate the amount based on the number of units consumed. The display_details method is used to print the flat number, owner name, previous reading, and current reading. The floor_details method is used to print the floor number, total units, and total amount. The floor number is determined by the first digit of the flat number.

This problem has been solved

Similar Questions

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

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

Write a C program to input electricity unit charges and calculate total electricity billaccording to the given condition:For first 50 units Rs. 0.50/unitFor next 100 units Rs. 0.75/unitFor next 100 units Rs. 1.20/unitFor unit above 250 Rs. 1.50/unitAn additional surcharge of 20% is added to the b

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…

1/2

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.