Advertisement
afrinahoque

Part 1

Dec 7th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.81 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4. #include<windows.h>
  5. #include<conio.h>
  6.  
  7. typedef struct node
  8. {
  9.     char foodname[30];
  10.     int data, stock;
  11.     float price;
  12.     struct node *next;
  13. }node;
  14.  
  15. node *head, *menu;
  16.  
  17. int credit_card[20];
  18. float total_poisa[20];
  19. char problem_box[20];
  20.  
  21. void print(char list[])
  22. {
  23.     printf("%s", list);
  24. }
  25.  
  26. void line(int cnt)
  27. {
  28.     int i;
  29.     for(i=1; i<=cnt; i++)
  30.         printf("\n");
  31. }
  32.  
  33. void tab(int cnt)
  34. {
  35.     int i;
  36.     for(i=1; i<=cnt; i++)
  37.         printf("\t");
  38. }
  39.  
  40. void scr()
  41. {
  42.     system("cls");
  43. }
  44.  
  45. foodlist()
  46. {
  47.     line(10); tab(20); print("1.   \"*Food Menu          |\"");line(2); Sleep(350);
  48.     line(10); tab(20); print("2.   \"*Admin Log In          |\"");line(2); Sleep(350);
  49.     line(10); tab(20); print("3.   \"*Rules & Reg          |\"");line(2); Sleep(350);
  50.     line(10); tab(20); print("4.   \"*Problem & Suggestion          |\"");line(2); Sleep(350);
  51.     line(10); tab(20); print("5.   \"*Exit          |\"");line(2); Sleep(350);
  52. }
  53.  
  54. void insertfood(char foodname[30], int data, int stock, float price)
  55. {
  56.     node *temp;
  57.     temp=(node*)malloc(sizeof(node));
  58.     temp->data=data;
  59.     temp->stock=stock;
  60.     temp->price=price;
  61.     strcpy(temp->foodname,foodname);
  62.     temp->next=NULL;
  63.  
  64.     if(head==NULL)
  65.     {
  66.         head=temp;
  67.         menu=head;
  68.     }
  69.     else
  70.     {
  71.         while(head->next!=NULL)
  72.         {
  73.             head=head->next;
  74.         }
  75.         head->next=temp;
  76.     }
  77. }
  78.  
  79. void foodlist()
  80. {
  81.     node *start;
  82.     start=menu;
  83.  
  84.     printf("---------------------------------------------------\n");
  85.     printf(" Item Number | Food Name | Price | Stock            \n");
  86.  
  87.     while(start!=NULL)
  88.     {
  89.         printf("---------------------------------------------------\n");
  90.         line(30); tab(30);
  91.         printf(" %d     | %s     | %d     | %.2f            \n", start->data, start->foodname, start->stock, start->price);Sleep(200);line(3);
  92.  
  93.         printf("---------------------------------------------------\n");
  94.  
  95.         start=start->next;
  96.     }
  97. }
  98.  
  99. int count()
  100. {
  101.     int cnt=0;
  102.  
  103.     node *temp;
  104.     temp=menu;
  105.  
  106.     while(temp!=NULL)
  107.     {
  108.         temp=temp->next;
  109.         cnt++;
  110.     }
  111.     return cnt;
  112. }
  113.  
  114. int total_money(int foodchoice, int much)
  115. {
  116.     scr();
  117.     node *temp;
  118.     temp=(node*)malloc(sizeof(node));
  119.     temp=menu;
  120.  
  121.     while(temp->data!=foodchoice)
  122.     {
  123.         temp=temp->next;
  124.     }
  125.     if(temp->data==foodchoice)
  126.     {
  127.         int o;
  128.         float total=temp->price*much;
  129.         line(3);tab(2); print("Total money for your order: ");line(2);
  130.         line(3);tab(2); printf("%.2f", total); line(2);
  131.         line(10);tab(20); print("Enter your table number: ");line(2);
  132.         line(10);tab(20); scanf("%d", &o);line(2);
  133.  
  134.         return total;
  135.     }
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement