computer programming problem please help Project 4 Due Segt 22, 201S At 2pm COP2
ID: 669307 • Letter: C
Question
computer programming problem
please help
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}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.