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

need help getting this program to run this is what I have so far #include <stdio

ID: 669586 • Letter: N

Question

need help getting this program to run


this is what I have so far

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

int main (void)
{
char ct;// customer type
char R; // stores resident
char G; // stores government
char C; // 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-500)*(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);
}
if(kwh>999&&kwh<=1999)
{
charge=(0.22*999)+(kwh-999)*(0.29);
}
else if(kwh>1999)
{
charge=((0.22*999)+(0.29*1000)+(kwh-1999)*(.45)+100);
}
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<=1500)
{
charge=(0.34*kwh);
}
if(kwh>1500&&kwh<=2500)
{
charge=(0.34*1500)+(kwh-1000)*(0.30);
}
else if(kwh>2500)
{
charge=((0.34*1500)+(0.30*1000)+((kwh-2500)*(.25)));
}
printf("%.2f", charge);
taxes=(charge*0);
printf("%.2f", taxes);
printf("%d", surcharge);break;
} // End Government Function}
}

Explanation / Answer

I didn't got any error in your code

just you have to modify the following

you have to remove two switch cases for commertial and government and add those cases in the switch statement declared for residential

i have modified the code as follows

and got the output as follows

I am not able to see the question image properly

if this code is not working for you. olease update the image and comment in the question , i will help you out

#include <stdio.h>
#include <math.h>
int main (void)
{
char ct;// customer type
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-500)*(0.35);
}
printf("%.2f ", charge);
taxes=(charge*0.075);
printf("%.2f ", taxes);
printf("%d ", surcharge);
break;// End Residential Function
case 'C':
case 'c':
if(kwh<=999)
{
charge=(0.22*kwh);
}
if(kwh>999&&kwh<=1999)
{
charge=(0.22*999)+(kwh-999)*(0.29);
}
else if(kwh>1999)
{
charge=((0.22*999)+(0.29*1000)+(kwh-1999)*(.45)+100);
}
printf("%.2f ", charge);
taxes=(charge*0.05);
printf("%.2f ", taxes);
printf("%d ", surcharge);
break;// End Commercial Function
case 'G':
case 'g':
if(kwh<=1500)
{
charge=(0.34*kwh);
}
if(kwh>1500&&kwh<=2500)
{
charge=(0.34*1500)+(kwh-1000)*(0.30);
}
else if(kwh>2500)
{
charge=((0.34*1500)+(0.30*1000)+((kwh-2500)*(.25)));
}
printf("%.2f ", charge);
taxes=(charge*0);
printf("%.2f ", taxes);
printf("%d ", surcharge);

break; // End Government Function
}
}

Output:

i am