subject

Write a program to create two types of utility bills: water bill and electricity bill. Both types of bills have customer’s 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 customer’s 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 customer’s 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 customer’s 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.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:30
To hide gridline when you display or print a worksheet
Answers: 1
question
Computers and Technology, 22.06.2019 20:40
Write a program that begins by reading in a series of positive integers on a single line of input and then computes and prints the product of those integers. integers are accepted and multiplied until the user enters an integer less than 1. this final number is not part of the product. then, the program prints the product. if the first entered number is negative or 0, the program must print “bad input.” and terminate immediately. next, the program determines and prints the prime factorization of the product, listing the factors in increasing order. if a prime number is not a factor of the product, then it
Answers: 2
question
Computers and Technology, 22.06.2019 20:50
What is the difference between windows 7 and windows 10?
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
Select the correct answer. andy received a potentially infected email that was advertising products. andy is at risk of which type of security threat? a. spoofing b. sniffing c. spamming d. phishing e. typo-squatting
Answers: 2
You know the right answer?
Write a program to create two types of utility bills: water bill and electricity bill. Both types of...
Questions
question
Physics, 16.07.2020 15:01
question
Geography, 16.07.2020 15:01
question
Geography, 16.07.2020 15:01
question
Mathematics, 16.07.2020 15:01
Questions on the website: 13722365