Question: PYTHON Write a program to create two types of utility bills: water bill and electricity bill. Both types of bills have customers name and address.

PYTHON Write a program to create two types of utility bills: water bill and electricity bill. Both types of bills have customers name and address. They calculate charge differently. Your project must follow these requirements.

(a) Create a Utility_bill class. This class has two protected instance variables: name and address. The __init__ method takes customers name and address as two arguments and stores them in the instance variables. Add another protected instance variable total and initialized it to 0. Define two abstract methods calculate_charge and display_bill. These abstract methods have no real code. There is only one statement to raise a NotImplementedError exception.

(b) Create a Water_bill class. This class is a derived class of the Utility_bill class. It has an additional protected instance variable to store number of gallons of water used. Define a calculate_charge method, which asks the user to enter number of gallons of water used and uses it to calculate total charge. Customers pay $0.005 per gallon for the first 6000 gallons, and $0.007 per gallon after the first 6000 gallons. Define a display_bill method to display customers name, address, number of gallons of water used and total charge.

(c) Create a Electricity_bill class. This class is a derived class of the Utility_bill class. It has an additional protected instance variable to store kilowatt hours used. Define a calculate_charge method, which asks the user to enter kilowatt hours used and uses it to calculate total charge. Customers pay $0.12 per kWh for the first 500 kWh, and $0.15 per kwh after the first 500 kWh. Define a display_bill method to display customers name, address, number of kWh used and total charge.

(d) In the main module, ask user to enter name and address. Ask the user to choose either water bill or electricity bill. Create an object and call its calculate_charge method to calculate total charge. Call the display_bill method to display the bill.

The following shows a sample test run. This user chooses water bill.

Enter name: John Doe

Enter address: 123 Happy Rd, Raleigh NC, 27603

Enter 1 for water bill, 2 for electricity bill: 1

How many gallons of water were used? 6002

Water Bill

Name: John Doe

Address: 123 Happy Rd, Raleigh NC, 27603

Gallons used: 6002.0

Please pay this amount: 30.014

The following shows another sample test run. This user chooses electricity bill.

Enter name: John Doe

Enter address: 123 Happy Rd, Raleigh NC, 27603

Enter 1 for water bill, 2 for electricity bill: 2

Enter kilowatt hours used: 502

Electricity Bill

Name: John Doe

Address: 123 Happy Rd, Raleigh NC, 27603

Kilowatt Hours used: 502.0

Please pay this amount: 60.3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!