Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

computer programming problem please help Project 4 Due Segt 22, 201S At 2pm COP2

ID: 669307 • Letter: C

Question

computer programming problem


please help

Project 4 Due Segt 22, 201S At 2pm COP2221-002 wene a C program to caculate utitity cost for ACME UTLITY COMPANY. The compaty as 3 tyses of ustomers (R) Residentia. I Cannertial and (Gl Government Cintorers we bled based on the umber of klowatts used and the type of cusomer they are iR C OR ) Residental customers are charged 0.25 cens per kilowatt hour for the Fest 500kw used, and 0.35 cent per kwh for al w used over 500 Commencial customens are charged 0.32 cents per kilowatt hour for the rst 999w used, 0 29 cents per kwh for alt w used over 999 kw up 0 1999 asd 0 45 cents per kwh for all kows sed greater thn 1999 Commercial customers that use er 2000 kw ane charged a special sarcharge of 300 0i adoition to the regular changes Government cunomers are charped 034 ceres ror the trst 1500 iwh ae1500. 30 cent for the t 1000 kwh uned (1501-2500ans 0.25 cents for all twn used r 2501) npat dislio Ermer customer type G4.RrC ar Gt 1program thouls accept only valid customer types customer type is soe case ot the customer esters an avald customer type prompt them to renter it) emer g or Q to quityou program should cantinue bo accept data and process bils until the ester Q or a is encered tor custonmer type Enter Klowatts used: 9999 99 Utility Charge $999 99 Tases $ 99 99 Amoust owed 59999 99 Surcharge: $10000

Explanation / Answer

#include <stdio.h>
#include <math.h>

int main (void)
{char ct;// customer type
char R; // stores resident
char G; // stores government
char A; // stores commercial
float kwh; // stores kwh
float charge; // stores the charge
float taxes; // stores taxes
int surcharge=100; // store surcharge

printf("Please enter customer type: (R) Residents, (G) Government, (C) Commercial enter Q to quit ");
scanf("%c", &ct);
printf("please enter kwh ");scanf("%f", &kwh);
switch(ct)
{
case 'R':
case 'r':
if(kwh<=500)
{
charge=(0.25*kwh);
}
else
{
charge=(0.25*500)+(kwh-501)*(0.35);
}
printf("%.2f", charge);
taxes=(charge*0.075);
printf("%.2f", taxes);
printf("%d", surcharge);
break;
}// End Residential Function
switch(ct)
{
case 'C':
case 'c':
if(kwh<=999)
{
charge=(0.22*kwh);
}
else
{
charge=(0.25*500)+(kwh-1000)*(0.29);
}
printf("%.2f", charge);
taxes=(charge*0.05);
printf("%.2f", taxes);
printf("%d", surcharge);
break;
} // End Commercial Function
switch(ct)
{ case 'G':
case 'g':
if(kwh<=2501)
{
charge=(0.25)*(kwh-2501);
}
else(kwh>1500);
{
charge=(0.34*1500)+(kwh-1000)*(0.29);
}
printf("%.2f", charge);
taxes=(charge*0.05);
printf("%.2f", taxes);
printf("%d", surcharge);break;
} // End Government Function}