im working on a basic till system
how can i get it so that the user can keep entering an item and price and such untill 0 is pressed.Code:#include<stdio.h>
void asci(void);//function prototype
void till(void);//function prototype
int item;//declaring variables
int quantity;//declaring variables
int price;//declaring variables
int x;//inner loop counter
int y;//outer loop counter
int main(void){
asci();//function call
int testnum = 0;
do{
printf("\nMenu Navigation\n0 = Exit\n1 = Item Input\nEnter a menu number = ");
scanf_s("%d", &testnum);
switch(testnum) {
case 0 : continue;
//now for the loop
//yer baby the loop.........
case 1 :till();//function call
break;
}
} while(testnum !=0);
printf("Loop complete\n");
return 0;
}
/**********************************************************************************/
/** Start of ASCI coding **/
/**********************************************************************************/
void asci(void)//function definition
{
/**print top line and ends **/
printf("\t%c",201);
for(x=1;x<60;x++)
printf("%c",205);
printf("%c\n",187);
/**print left and right edges **/
printf("\t%c Basic Till %c\n",186,186);
printf("\t%c Software Menu %c\n",186,186);
for(x=y;y<1;y++){ //y< sets the height of the menu
printf("\t%c",186);
for(x=1;x<60;x++)
printf("%c",' ');
printf("%c\n",186);
}
/**print bottom lines and edges **/
printf("\t%c",200);
for(x=1;x<60;x++)
printf("%c",205);
printf("%c\n\n",188);
}
/**********************************************************************************/
/** Start of till coding **/
/**********************************************************************************/
void till(void)//function definition - used for the till selection
// here we add item name, quantity and price
{
puts("\nItems List\n"); //main till functions, select items, select quantity, select price
printf("Enter Item Name = "); //Item
scanf_s("%d",&item);
printf("Enter Quantity = "); //Quantity
scanf_s("%d",&quantity);
printf("Enter Price = "); //Price
scanf_s("%d",&price);
//this wonderfull code will add it all up for you
int multiply_stuff = quantity * price; //this deals with the total item price of whats been ordered.
//quantity multiplyed by price = total
printf("Product Name: %d :: Item Quantity: %d :: Item Price: = %d :: Total For Item: = %d ",item,quantity, price, multiply_stuff);
}
//end the wonderfull adding up code
Also how can i output this information into a file or on screen?
dan