Question: Here is my code, it says there is an error with the else statements not having a previous if but they do. How can I

Here is my code, it says there is an error with theHere is my code, it says there is an error with the else statements not having a previous if but they do. How can I fix that?

#include #include

int main() { double a, b, c, d, e, f, g, h; scanf("%lf", &a); if (a > 250) b= (a-250)*10.25; c= 150*9.8; d= 100*9.5; e= 50*8.5; f= b+c+d+e; else if ((a 150)) b= (a-150)*9.8; c= 0; d= 100*9.5; e= 50*8.5; f= b+c+d+e; else if ((a 50)) b= 0; c= 0; d= (a-50)*9.5; e= 50*8.5; f= b+c+d+e; else b= 0; c= 0; d= 0; e= a*8.5; f= b+c+d+e;

g = f*(.2); h= f+g; printf(" The total bill is $%.2f", h); }

Electricity bill Write a program that reads the electricity consumption (in kWh) and computes the electricity bill based on the following information: The first 50 kWh costs 8.5 cents/kWh Next 100 kWh costs 9.5 cents/kWh Next 100 kWh costs 9.8 cents/kWh The consumption above 250 kWh costs 10.25 cents/kWh Additional surcharge 20% is added to the bill. The input of the program is one integer and the output will be "The total bill is $X.", where X is the price of electricity rounded to two decimal places. Example of input: 303 Corresponding output: The total bill is $34.78

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!