Question: Problem 3 : Energy consumption ( if - else ) Write a C + + program to calculate the total energy consumption and cost for
Problem : Energy consumption ifelse
Write a C program to calculate the total energy consumption and cost for a smart home with different types of devices. The program should prompt the user to input the number of hours air conditioner, lights and appliances were used. The cost per kWh is $ The program should only accept whole hours as input, ignoring minutes and seconds eg hours, hours are valid inputs The hours must be within the range of to The energy consumption rates for each type of device are as follows:
Air conditioner: kWh per hour.
Lights: kWh per hour.
Home appliances: kWh per hour.
The program computes the following discounts on energy costs:
If the total energy consumption is less than or equal to kWh no discount is applied.
If the total energy consumption is between kWh and kWh included apply a discount on the total cost.
If the total energy consumption is more than kWh apply a discount on the total cost.
The program should display:
The total energy consumption.
The total cost before the discount.
The total cost after the discount only if there was a discount
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
