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;
}