- Home >
- Programming >
- Intro to Programming using C
Intro to Programming using C
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 first 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
This question has not been answered.
Create a free account to get help with this and any other question!
Similar Content
Breakfast at Tiffanys
by Truman Capote
American Gods
by Neil Gaiman
The Nightingale
by Kristin Hannah
The Odyssey
by Homer
The Remains Of The Day
by Kazuo Ishiguro
Death Of A Salesmen
by Arthur Miller
Broke Millennial: Stop Scraping by and Get Your Financial Life Together
by Erin Lowry
A Wrinkle as Time
by Madeleine L'Engle
The Glass Castle
by Jeannette Walls
Studypool values your privacy. Only questions posted as Public are visible on our website.
Brown University
1271 Tutors
California Institute of Technology
2131 Tutors
Carnegie Mellon University
982 Tutors
Columbia University
1256 Tutors
Dartmouth University
2113 Tutors
Emory University
2279 Tutors
Harvard University
599 Tutors
Massachusetts Institute of Technology
2319 Tutors
New York University
1645 Tutors
Notre Dam University
1911 Tutors
Oklahoma University
2122 Tutors
Pennsylvania State University
932 Tutors
Princeton University
1211 Tutors
Stanford University
983 Tutors
University of California
1282 Tutors
Oxford University
123 Tutors
Yale University
2325 Tutors