Question
US Government Website says the following interesting information: In 2017, the average annual electricity consumption for a U.S. residential utility customer was 10,399 kilowatthours (kWh),
US Government Website says the following interesting information: In 2017, the average annual electricity consumption for a U.S. residential utility customer was 10,399 kilowatthours (kWh), an average of 867 kWh per month. Louisiana had the highest annual electricity consumption at 14,242 kWh per residential customer, and Hawaii had the lowest at 6,074 kWh per residential customer
Let us compute the electricity usage and the bill for last month by asking a few questions to a homeowner. Here are the input parameters and output format.
Input: # of light bulbs Average
# of hours each bulb is ON in a day AC unit's power Typical
# of hours AC unit is ON in a day
# of FANs Average
# of hours each Fan is ON in a day Per-unit price of electricity
Formatted output: Total electricity usage: NNNN kWh
Bulbs: XX.X% AC: YY.Y% FANs: ZZ.Z%
Electricity bill for the month: $ NNNN.NN
- Assume that each bulb consumes 60W and each fan consumes 40W.
- Assume that the home has only one AC unit and all other appliances including cooking range use other energy sources, NOT electricity. AC unit power is specified in watts.
- 1 kWh stands for 1000 Watt-hours and it is considered as 1 unit of Electricity and the per-unit price is specified in cents.
- Assume that the last month had 30 days
#include
int main() { // Used to store the numbers of Bulbs & fans int numBulbs, numFans; // Used to store Bulb, AC, Fan hours of on double hrsBulbOn, hrsFanOn, unitAC, hrsACOn, unitPrice; // Used ot store calculated values double totalBulb, totalFan, totalAC, totalConsumption; double percentBulb, percentFan, percentAC; double billAmount; // Take number of Bulbs printf("# of light bulbs: "); scanf("%d", &numBulbs); // Take number of hours each bulbs on printf("Average # of hours each bulb is ON in a day: "); scanf("%d", &hrsBulbOn); // Take AC unit power printf("AC unit's power: "); scanf("%d", &unitAC); // Take number of hours AC on printf("Typical # of hours AC unit is ON in a day: "); scanf("%d", &hrsACOn); // Take number of fans printf("# of FANs: "); scanf("%le", &numFans); // Take number of hours fan on printf("Average # of hours each Fan is ON in a day: "); scanf("%d", &hrsFanOn); // Take unit price of electricity printf("Per-unit price of electricity: "); scanf("%d", &unitPrice); // Compute the consumption by bulbs totalBulb = (numBulbs*hrsBulbOn*60*30)/1000.0; // Compute the consumption by fans totalFan = (numFans*hrsFanOn*40*30)/1000.0; // Compute the consumption by AC totalAC = (hrsACOn*unitAC*30)/1000.0; // Compute total consumption totalConsumption = totalBulb + totalFan + totalAC; // Compute the percentage consumption by Bulbs percentBulb = (totalBulb/totalConsumption)*100.0; // Compute the percentage consumption by fans percentFan = (totalFan/totalConsumption)*100.0; // Compute the percentage consumption by AC percentAC = (totalAC/totalConsumption)*100.0; // Compute the bill amount billAmount = totalConsumption*(unitPrice*0.01); // Display the output printf("Total electricity usage: ", totalConsumption); printf("Bulbs: ", percentBulb); printf("% AC: ", percentAC); printf("% Fans: ", percentFan "%"); printf("Electricity bill for the month: $ ", billAmount);
return 0; } I do not know what is wrong with my code pls help
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started