We have selected to write a program to create a shop billing program which will allow user to input item details such as name, price, quantity, vat etc . And allow further entry of details by user to calculate the total cost. The Last Output will be shown as a bill. You Can see your previous purchases etc.
7. {
printf("ntPRODUCT ID :- %d",ad.item_id);
printf("ntPRODUCT NAME :- %s",ad.item_name);
printf("ntPRODUCT PRICE :- %f",ad.price);
printf("nn");
i++;
}
}
fclose(fp);
printf("nnt 1. TO GO TO MENU PAGE nnt2. TO EXIT :-t");
scanf("%d",&q);
return q;
}
int generate_bill()
{
time_t now;
struct tm *d;
int w=0;
int item_id,f=1,i=0,n=0,p=0,bill_id=0,k=1,j=0;
float total=0,quant=0;
bifp=fopen("GBill.txt","a");
fclose(bifp);
while(f==1)
{
int flag=0;
system("cls");
if(j==0)
{
bifp=fopen("GBill.txt","r");
while((fread(&bi,sizeof(bi),1,bifp))==1)
{
bill_id=bi.bill_id;
}
bill_id++;
bi.bill_id=bill_id;
fclose(bifp);
j++;
}
printf("tNOTE :- JUST ENTER PRODUCT ID OF BUYING PRODUCTS
TO CALCULATE BILL");
printf("nntPRODUCT ID :-t");
scanf("%d",&item_id);
fp=fopen("Products.txt","r");
8. while((fread(&ad,sizeof(ad),1,fp))==1)
{
if(item_id==ad.item_id)
{
printf("nntPRODUCT NAME :- %s",ad.item_name);
strcpy(bi.item_name[i],ad.item_name);
printf("tPRODUCT PRICE :- %f",ad.price);
bi.price[i]=ad.price;
printf("nn");
flag=1;
}
}
if(flag==0)
{
printf("nntYOUR PRODUCT ID IS NOT FOUND.");
}
else
{
printf("nntQUANTITY OF PRODUCT :-t");
scanf("%f",&quant);
bi.quant[i]=quant;
total=total+quant*ad.price;
bi.total=total;
flag=0;
bi.n=i;
n=i;
i++;
}
fclose(fp);
printf("nnnt 1. TO ADD MORE PRODUCT nnnt2. TO GO TO BILL
PAGE : ");
scanf("%d",&f);
}
system("cls");
printf("ntPUT DOWN CUSTOMER INFORMATION .....");
printf("nntCUSTOMER NAME :- ");
scanf("%s",&bi.cust_name);
time(&now);
d=localtime(&now);
strftime(bi.date, 15, "%d/%m/%Y", d);
printf("nnnt 1. TO GENERATE A BILL nnt2. TO GO TO MAIN MENU : ");
scanf("%d",&p);
if(p!=1)