Build a program to create two types of utility bills

Assignment Help Python Programming
Reference no: EM132355784

Question

Build 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.

(a) Design 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) Design 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) Build an 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. Build 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

Reference no: EM132355784

Questions Cloud

What is firm equity market beta : An identical firm that is entirely equity -financed has a market beta of 1.2. What is your firm's equity market beta?
What is bram market beta : The average annual return of the market portfolio is 12.5%, with a standard deviation of 4%. The covariance of the returns is 28.8%%. What is Bram's market beta
Write a function that returns the length and starting index : Longest sorted subsequence. Write a function longest_monot one ( ) that returns the length and starting index of the longest contiguous sorted.
What is the? firm debt? ratio : Dearborn Supplies has total sales of $ 207 ?million, assets of $ 97 ?million, a return on equity of 35 ?percent, and a net profit margin of 7.8 percent.
Build a program to create two types of utility bills : Define a calculate_charge method, which asks the user to enter kilowatt hours used and uses it to calculate total charge.
Company x largest shareholder is company y : Company X's largest shareholder is Company Y, which owns one out of every 8 outstanding shares of stock of X. Company X in turn owns 27% of Company Z
Write a function that output the position of minimum element : Position of minimum elemement. Write a function that outputs the position of the minimum element in an array of integers.
What is the difference between the retail or client market : What is the difference between the retail or client market and the wholesale or interbank market for foreign exchange?
Advantages and disadvantages of the gold standard : Describe the advantages and disadvantages of the gold standard.

Reviews

Write a Review

Python Programming Questions & Answers

  Grade that will calculate and return a student''s exam

Write a function overall Grade that will calculate and return a student's 2316 exam average. It will accept five parameters, which correspond to exam1,2,3,4 and the Final grade. It should replace the lowest exam grade with the 2nd lowest exam grade

  How catch market trends

How catch market trends? Crossing n1­days moving average (MA) and n2­days moving average (n1>n2). When n2­days MA crosses n1­days MA, it is an indicator for the start of upward trend, and the other way around for downward trend

  Write python code to load your dataset into a pandas data

A medium-size Australian company imaginary has given you one year of data about the online purchases that their customers have made.

  Calculate the areas of two different rectangles

You need assistance in creating a program using Flowgorithm to calculate the areas of two different rectangles and then determine which is greater or if the are

  Calculate and display the total rainfall for the year

Climate data is collected on each city and state. Design a program that lets the user enter the total rainfall for each of 12 months into a list.

  Implement a voting test

Implement a voting test. The user enters their age and then the program prints either, "You must be 18 to vote" or "You are of voting age"

  How do you make a function that prompt the user to enter

How do you make a function that prompt the user to enter two sentences. Then it will print a combined sentence, consisting of alternating words.

  Write Python program that generates an informative web site

ICT112 Assignment - Generated Web Site for Aussie Airport Passenger Movements. University of the Sunshine Coast. write a Python program that generates a site

  Write new python program that contains a main function

Start with a comment that includes your name and course number. Include pseudocode that describes all steps required to solve the problem.

  The function should return the day name (''su'',''mo''..etc)

Write the function day(d,m) where m is an integer from 1 through 12 expressing a month, and d is an integer from 1 through 31 expressing the day part of a date in 2014.

  Exploration of online social networking

This assignment will allow you to do a more open-ended exploration of online social networking. The goal is to let you use some of the tools we've learned in class on your own

  Write program that will calculate a tip and a tax on a meal

Write a program that will calculate a XXX% tip and a 6% tax on a meal price. Each programming assignment should have the following header, with italicized text appropriately replaced.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd