Reference no: EM132357174
Question
Objective To write a program that calculates kilowatt - hour electrical appliance usage.
PROJECT DESCRIPTION
Write a program that calculates the annual cost of running various appliances. For each appliance, the program will request that the user enter the cost per kilowatt - hour and the number of kilowatt - hours the appliance uses in a year.
Sample run of the program is shown below showing input gathered and a resulting output total displayed.
Please enter the appliance name: central air
Please enter the cost per KW - hr of the appliance (in cents): .17
Please enter the annual usage (in KW - hr): 1400
Please enter the appliance name: dishwasher
Please enter the cost per KW - hr of the appliance (in cents): .17
Please enter the annual usage (in KW - hr): 25
Please enter the appliance name: electric range
Please enter the cost per KW - hr of the appliance (in cents): .16
Please enter the annual usage (in KW - hr): 52
Please enter the appliance name: refrigerator
Please enter the cost per KW - hr of the appliance (in cents): .15
Please enter the annual usage (in KW - hr): 175
Please enter the appliance name: toaster
Please enter the cost per KW - hr of the appliance (in cents): .15
Please enter the annual usage (in KW - hr): 4
Please enter the appliance name: washing machine
Please enter the cost per KW - hr of the appliance (in cents): .16
Please enter the annual usage (in KW - hr): 9
The total cost of the annual usage is $ 278.86.
Information about This Project
When you purchase electricity you are charged by the kilowatt - hour ( kWh ) . For example, when you use 1,000 watts for 1 hour, that is one kilowatt - hour.
Steps To Complete This Project
STEP 1 Open the Python IDLE IDE and Write the Program Code
Open the Python IDLE IDE ( Integrated Development Environment ) on your computer.
You'll notice when you initially open python the default is an interpretive shell allowing only for single commands to be given. You really need to enter in a whole program then execute it to work any of the labs for the course. To start entering code into IDLE go to File > New File from your menu. This will allow you to enter your source code in an editor style format like notepad.
At any point your can save your file. It will prompt you to do so when you go to run your program. You may save your file anytime to a designation of your choice. The extension will always be .py.
In the editor you may begin typing your source code. Here are some thoughts to assist you in writing the program code.
For all your labs include comments where applicable in your code that explains a
bit what your assigning as variables as an example or what a loop will perform or a method, etc. To enter in a comment anywhere in code include a hash tag
( # ).
Example:
#local variable declarations
totalCost = 0.0 # declare variable a float type/use is to accumulate total charges
Have your program perform the following logic:
Write the program code that will allow the user to enter the necessary input items listed in the project description area above (check the sample run provided) and then use these items to compute the required output value, that is, the annual usage charge. The annual usage charge is based on cost * kWh usage as mentioned above per a given appliance. Accumulate a sum total of all annual usage charges and display your result at the end of the program.