# Thread: Homework HELP! CProgram Electric Company

1. yaaaaa i figured that out but thats how i got 18.75 :/
Code:
```
#include <stdio.h>

int main (void)
{
int custnum;
int  kwh, copy;
double totalo=0.0;
double totald=0.0;
double totalt=0.0;
double totalf=0.0;
double finaltotal=0.0;

while(1) {
printf("\nEnter Customer Number or enter -1 to quit>");
scanf("%d", &custnum);

if (custnum == -1)
break;

printf("Enter kwh for customer %d>", custnum);
scanf("%d", &kwh);
copy = kwh;
while(kwh > 1000) {  //needs to loop if kwh > 2000
totalf += (kwh - 1000) * 0.05;  //needs += instead of =
kwh -= 1000;
}
if(kwh > 600) {   //will never loop
totalt = (kwh - 600) * 0.06;
kwh -= 600;
}
if(kwh > 300) {  //will never loop
totald = (kwh - 300) * 0.08;
kwh -= 300;
}
if(kwh) {
totalo = 0.09 * kwh;
kwh = 0;
}
finaltotal = totalo + totald + totalt+ totalf;
kwh = copy;
printf("\nCustomer number %d used %d kwh, and charged \$%.2f\n",
custnum, kwh, finaltotal);
//prepare for next customer:
finaltotal = totalo = totald = totalt = totalf = 0;
}

(void) getchar();
system ("pause");
return 0;

}```

2. I just posted the updated code. Why are you reposting the obsolete code that I already said, was inaccurate?

What we have here << rifle shot >> is a failure to communicate!

Read my last post and try out the code at the bottom of that post.

3. Sorry my bad my computer wasnt showing the code you posted

4. Done that a few times, myself. Hit the Back arrow in the browser, and forget that it's not updated stuff that you're now looking at.

5. It works perfectly thanks

6. You're welcome, but study it well -- quiz next Friday.