# DETAILED PROGRAM

*label*Programming

*timer*Asked: Oct 11th, 2013

**Question description**

Write a program energy.c in C that calculates an electricity bill for an electric company that provides a credit for user-generated energy (e.g. from solar panels). Your program will prompt the user for the amount of energy consumed and the amount of energy generated. Note that the user input is / delimited. The bill will be calculated according to a tiered pricing model applied to kilowatt-hours (kWh) consumed and generated. For energy generated, the user is always credited $0.10/kWh. For energy consumed, the ﬁrst 300 kWh are charged at a rate of $0.15/kWh. Energy consumed beyond 300 kWh is charged at a rate of $0.30/kWh. The energy company likes their calculations to have at least 10 digits of precision and for the price to be returned to the millionth dollar ($0.000001), so choose your variable data types accordingly and format your output as shown below.

a.out

How many kWh were consumed/generated? 1/0

Your bill is: $0.150000

(˜)$ a.out

How many kWh were consumed/generated? 100 / 1

Your bill is: $14.900000

(˜)$ a.out

How many kWh were consumed/generated? 400/ 100

Your bill is: $65.000000

(˜)$ a.out

How many kWh were consumed/generated? 500.12345 /2000.4521

Your bill is: $-95.008175