// eectric.c -- calculates electric bill
#include <stdio.h>

// rate for first 240 kWh
const double RATE1 = 0.11439;
// rate for next 300 kWh
const double RATE2 = 0.12032;
// rate for ver 540 kWh
const double RATE3 = 0.14022;
// first breakpoint for rates
const double BREAK1 = 240.0;
// second breakpoint for rates
const double BREAK2 = 540.0;
// cost for 240 kWh
const double BASE1 = (RATE1 * BREAK1);
// cost for 540 kWh
const double BASE2 = (BASE1 + (RATE2 * (BREAK2 - BREAK1)));

int main(void)
{
	// kilowatt hours used
	double kwh;
	// charges
	double bill;

	printf("Please enter the kWh used: ");
	// %lf for double type
	scanf("%lf", &kwh);
	
	if (kwh < BREAK1)
		bill = RATE1 * kwh;
	else if (kwh <= BREAK2)
		// kWh between 240 and 540
		bill = BASE1 + (RATE2 * (kwh - BREAK1));
	else
		bill = BASE2 + (RATE3 * (kwh - BREAK2));

	printf("The charge for %.1f kWh is $%1.2f.\n", kwh, bill);
	return 0;
}