Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- int main()
- {
- FILE *fp;
- int n,p,num,ch;
- char ope;
- char s[25],str[100][20];
- int price[100];
- do
- {
- printf("\t\t\t\t\t\t\t TAJAMHAL FOOD\t\t\n");
- printf("Press 1 to entry item and Further process\nPress 2 to show item and Further process\n");
- scanf("%d",&ch);
- printf("\n\n");
- switch(ch)
- {
- case 1:
- {
- fp=fopen("input.txt","w");
- if(fp==NULL)
- {
- printf("Error!! Opening FIle\n");
- return 1;
- }
- printf("Enter The Total Number of Items: \n");
- scanf("%d",&n);
- fprintf(fp, "%d\n", n);
- printf("Enter Item Name & Price: \n");
- for(int i=1; i<=n; ++i)
- {
- scanf("%s %d",s, &p);
- fprintf(fp, "%s %d\n", s,p);
- }
- fclose(fp);
- }
- case 2:
- {
- fp=fopen("input.txt","r");
- rewind(fp);
- fscanf(fp, "%d", &num);
- for(int i=1; i<=num; ++i)
- {
- fscanf(fp, "%s %d",str[i],&price[i]);
- }
- fclose(fp);
- printf("\n\t\t\t\t\t\t\t Cash Memo\t\t\n");
- printf("\t\t\t\t\t\t*********************************\t\t\n");
- for(int i=1; i<=num; ++i)
- {
- printf("\t\t\t\t\t%d. %s = %d\n", i, str[i], price[i]);
- }
- }
- printf("\n\n");
- }
- printf("Press 0 to End: \n");
- int idx[25], quantity[25], total = 0, id;
- for(id=1;;++id) {
- scanf("%d",&idx[id]);
- if(idx[id]==0) break;
- scanf("%d",&quantity[id]);
- total += price[idx[id]] * quantity[id];
- }
- for(int j=1;j<id;++j) {
- printf("%d %s %d %d\n", j, str[idx[j]], quantity[j], price[idx[j]] * quantity[j]);
- }
- printf("\n\n\n\tTotal money: %d\n", total);
- printf("\n\n\nDo You Want to Continue?\nPress y to Continue.\nAny other key to exit.\n");
- getchar();
- ope=getchar();
- system("cls");
- }
- while(ope=='y');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement