ahahaha thanks it works now but if i enter multiple entries like "1" twice for the product number it stops automaticaly -.-'
Code:
#include <stdio.h>
int main (void)
{
int custnum;
int kwh, copy;
double totald=0.0;
double totala=0.0;
double totalb=0.0;
double totalc=0.0;
double totale=0.0;
while(1) {
printf("\nEnter Product Number or enter 0 to quit>");
scanf("%d", &custnum);
if (custnum == 0)
break;
printf("Enter Quality Sold >", custnum);
scanf("%d", &kwh);
copy = kwh;
if(custnum == 1) {
totala += (kwh * 2.98);
printf("\nEnter Product Number or enter 0 to quit>");
scanf("%d", &custnum);
if (custnum == 0)
break;
printf("Enter Quality Sold >", custnum);
scanf("%d", &kwh);
copy = kwh;
}
if(custnum == 2) {
totalb = (kwh * 4.50);
printf("\nEnter Product Number or enter 0 to quit>");
scanf("%d", &custnum);
if (custnum == 0)
break;
printf("Enter Quality Sold >", custnum);
scanf("%d", &kwh);
copy = kwh;
}
if(custnum == 3) {
totalc = (kwh * 9.98);
printf("\nEnter Product Number or enter 0 to quit>");
scanf("%d", &custnum);
if (custnum == 0)
break;
printf("Enter Quality Sold >", custnum);
scanf("%d", &kwh);
copy = kwh;
}
if(custnum == 4) {
totald = (kwh * 4.49);
printf("\nEnter Product Number or enter 0 to quit>");
scanf("%d", &custnum);
if (custnum == 0)
break;
printf("Enter Quality Sold >", custnum);
scanf("%d", &kwh);
copy = kwh;
}
if(custnum == 5) {
totale = (kwh * 6.87);
printf("\nEnter Product Number or enter 0 to quit>");
scanf("%d", &custnum);
if (custnum == 0)
break;
printf("Enter Quality Sold >", custnum);
scanf("%d", &kwh);
copy = kwh;
}
kwh = copy;
printf("\nProduct 1 : $%.2f\n",
totala);
printf("\nProduct 2 : $%.2f\n",
totalb);
printf("\nProduct 3 : $%.2f\n",
totalc);
printf("\nProduct 4 : $%.2f\n",
totald);
printf("\nProduct 5 : $%.2f\n",
totale);
totala = totalb = totalc = totald = totale = 0;
}
(void) getchar();
system ("pause");
return 0;
}