Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 61.77 KB | None | 0 0
  1. /*
  2. SUBJECT       : COMPUTER SCIENCE UNIT 2
  3. PROGRAM       : INVENTORY & POINT OF SALE SYSTEM
  4. */
  5.  
  6.  
  7. #include <stdio.h>
  8. #include <string.h>
  9. #include <unistd.h>
  10. #include <stdlib.h>
  11. #include <time.h>
  12.  
  13. #define minlength 5
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20. /*VARIABLES*/
  21. int x,y,z,a,b,choice,admit,idno,workerCNT;
  22. int itemCNT;
  23. int posCNT;
  24. char container[255];
  25. float floatcontainer;
  26. int currentlogin;
  27.  
  28. char user[15];
  29. char username[10];
  30. char password[20];
  31.  
  32. char adminusername[10] = "Admin";
  33. char adminpassword[20] = "password";
  34. char confirmpassword[20];
  35. char testpassword[20];
  36. int strlen1;
  37. int strlen2;
  38.  
  39. char remitemname[100];
  40.  
  41.  
  42. struct employee{
  43.     char username[10][100];
  44.     char password[10][100];
  45.     char fname[15][100];
  46.     char mname[15][100];
  47.     char lname[15][100];
  48.     char dob[15][100];
  49.     int gender;
  50.     int male[100];
  51.     int female[100];
  52.     char deleteID[12];
  53. }record;
  54.  
  55. struct stockpile{
  56.  char itemname[10000][20];
  57.  float stock[10000];
  58.  float sp[10000];
  59.  float bp[10000];
  60.  float sold[1000];
  61.  float spoiltquantity[10000];
  62.  float spoiltloss[10000];
  63.  float profit_loss[10000];
  64.  float price;
  65.  float networth;
  66.  float asset;
  67.  float assetloop[10000];
  68.  float totalprofit;
  69. }inventory;
  70.  
  71. struct cashregister{
  72.  char itemname[1000][20];
  73.  float quantity[1000];
  74.  float price[1000];
  75.  float sp[1000];
  76.  float pricenotax;
  77.  float tax;
  78.  int transaction;
  79.  float subtotal;
  80.  float total;
  81.  float cashtendered;
  82.  float change;
  83.  float subloop;
  84. }pos;
  85.  
  86. char workusername[10][1000];
  87.  
  88.  
  89.  
  90.  
  91.  
  92. /*FUNCTION TO ADD ITEMS TO THE INVENTORY*/
  93. void additem()
  94.  {
  95.                                    choice=0;
  96.                                    while(choice != 2)
  97.                                     {
  98.                                      x=itemCNT;
  99.                                      printf("\n\n");
  100.                                      printf("Enter the name of the item: ");
  101.                                      scanf("%s", container);
  102.                                      for (a=0;a<itemCNT;a++)
  103.                                       {
  104.                                         if (strcmp(container,inventory.itemname[a]) == 0)
  105.                                          {
  106.                                             admit = 1;
  107.                                             break;
  108.                                          }
  109.                                         else
  110.                                          admit = 0;
  111.                                       }
  112.                                      if (admit == 1)
  113.                                       {
  114.                                         printf("\n\n");
  115.                                         printf("THAT ITEM HAS ALREADY BEEN USED. NO DUPLICATE ITEMNAMES IN THE INVENTORY...");
  116.                                         sleep(3);
  117.                                       }
  118.                                      else
  119.                                       {
  120.                                          strcpy(inventory.itemname[x],container);
  121.                                          printf("Enter the quantity: ");
  122.                                          scanf("%f", &inventory.stock[x]);
  123.                                          printf("Enter the price bought: ");
  124.                                          scanf("%f", &inventory.bp[x]);
  125.                                          printf("Enter the price to be sold: ");
  126.                                          scanf("%f", &inventory.sp[x]);
  127.                                          x++;
  128.                                          itemCNT++;
  129.                                          inventory.networth = inventory.bp[x] * inventory.stock[x];
  130.                                
  131.                                          printf("\nItem successfully added. Add another? Enter '1' for yes and '2' for no: ");
  132.                                          scanf("%d", &choice);
  133.                                          
  134.                                          if (choice == 2)
  135.                                           {
  136.                                             choice = 0;
  137.                                             break;
  138.                                           }
  139.                                       }
  140.                                     }
  141.                                    
  142.  }
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149. /*FUNTION TO EDIT ITEM IN THE INVENTORY*/
  150. void edititem()
  151.  {
  152.                                       printf("\n\n\n\n\n");
  153.                                       printf("***********************************************************************************************************************************************************************\n");
  154.                                       printf("|  ID#   |            ITEM            |  STOCK  |  BUYING PRICE  |  SELLING PRICE  |     SOLD     |   SPOILT QNTY   |   SPOILT LOSS   |          PROFIT/LOSS          |\n");      
  155.                                       printf("***********************************************************************************************************************************************************************\n\n");
  156.                                       printf("%4d", a);
  157.                                       printf("%26s", inventory.itemname[a]);
  158.                                       printf("%15.1f", inventory.stock[a]);
  159.                                       printf("%15.2f", inventory.bp[a]);
  160.                                       printf("%17.2f", inventory.sp[a]);
  161.                                       printf("%16.1f", inventory.sold[a]);
  162.                                       printf("%17.1f", inventory.spoiltquantity[a]);
  163.                                       printf("%19.2f", inventory.spoiltloss[a]);
  164.                                       printf("%29.2f", inventory.profit_loss[a]);
  165.                                    
  166.                                     while (choice != 6)
  167.                                      {
  168.                                         printf("\n\n\n\n\n\n\n");
  169.                                         printf("Edit what about the item: \n\n");
  170.                                         printf(" 1] Name\n");
  171.                                         printf(" 2] Buying price\n");
  172.                                         printf(" 3] Selling price\n");
  173.                                         printf(" 4] Stock\n");
  174.                                         printf(" 5] Amount Sold\n");
  175.                                         printf(" 6] Exit\n\n");
  176.                                        
  177.                                         printf("Choice: ");
  178.                                         scanf("%d", &choice);
  179.                                         printf("\n\n\n\n");
  180.                                        
  181.                                         if (choice == 6)
  182.                                          {
  183.                                             choice == 0;
  184.                                             break;
  185.                                          }
  186.                                          
  187.                                         if (choice == 1)
  188.                                          {
  189.                                             printf("ENTER NEW ITEM NAME: ");
  190.                                             scanf("%s", inventory.itemname[a]);
  191.                                             printf("\n\n");
  192.                                             printf("SUCCESSFUL");
  193.                                             sleep(3);
  194.                                          }
  195.                                          
  196.                                         if (choice == 2)
  197.                                          {
  198.                                             printf("ENTER NEW BUYING PRICE: ");
  199.                                             scanf("%f", &inventory.bp[a]);
  200.                                             printf("\n\n");
  201.                                             printf("SUCCESSFUL");
  202.                                             sleep(3);  
  203.                                          }
  204.                                          
  205.                                         if (choice == 3)
  206.                                          {
  207.                                             printf("ENTER NEW SELLING PRICE: ");
  208.                                             scanf("%f", &inventory.sp[a]);
  209.                                             printf("\n\n");
  210.                                             printf("SUCCESSFUL");
  211.                                             sleep(3);
  212.                                          }
  213.                                          
  214.                                         if (choice == 4)
  215.                                          {
  216.                                             printf("ENTER NEW STOCK: ");
  217.                                             scanf("%s", inventory.stock[a]);
  218.                                             printf("\n\n");
  219.                                             printf("SUCCESSFUL");
  220.                                             sleep(3);
  221.                                          }
  222.                                          
  223.                                         if (choice == 5)
  224.                                          {
  225.                                             printf("ENTER NEW AMOUNT SOLD: ");
  226.                                             scanf("%s", inventory.sold[a]);
  227.                                             printf("\n\n");
  228.                                             printf("SUCCESSFUL");
  229.                                             sleep(3);
  230.                                          }
  231.                                      }
  232.  }
  233.  
  234.  
  235.  
  236.  
  237.  
  238. /*FUNCTION TO PRINT INVENTORY IN THE MAIN FUNCTION*/
  239. void inventoryprint()
  240.  {
  241.                             printf("\n\n\n\n\n");
  242.                             printf("***********************************************************************************************************************************************************************\n");
  243.                             printf("|  ID#   |            ITEM            |  STOCK  |  BUYING PRICE  |  SELLING PRICE  |     SOLD     |   SPOILT QNTY   |   SPOILT LOSS   |          PROFIT/LOSS          |\n");      
  244.                             printf("***********************************************************************************************************************************************************************\n\n");
  245.        
  246.                               for(y=0;y<itemCNT;y++)
  247.                                {
  248.                                        
  249.                                         printf("%4d", y);
  250.                                         printf("%26s", inventory.itemname[y]);
  251.                                         printf("%15.1f", inventory.stock[y]);
  252.                                         printf("%15.2f", inventory.bp[y]);
  253.                                         printf("%17.2f", inventory.sp[y]);
  254.                                         printf("%16.1f", inventory.sold[y]);
  255.                                         printf("%17.1f", inventory.spoiltquantity[y]);
  256.                                         printf("%19.2f", inventory.spoiltloss[y] = inventory.spoiltquantity[y]*inventory.bp[y]);
  257.                                         printf("%29.2f", inventory.profit_loss[y] = ((inventory.sp[y]-inventory.bp[y])*inventory.sold[y]) - inventory.spoiltloss[y]);
  258.                                 printf("\n\n");
  259.                                }
  260.                          
  261.                           inventory.asset = 0;
  262.                           inventory.networth = 0;
  263.                           inventory.totalprofit = 0;               
  264.                           for (a=0;a<itemCNT;a++)
  265.                            {
  266.                                 inventory.totalprofit = inventory.totalprofit + inventory.profit_loss[a];
  267.                                 inventory.assetloop[a] = (inventory.bp[a]*inventory.stock[a]); 
  268.                                 inventory.asset = inventory.asset + inventory.assetloop[a];
  269.                            }
  270.                           inventory.networth = (inventory.asset + inventory.totalprofit);
  271.                           printf("\n\n\n\nTOTAL PROFIT = $");
  272.                           printf("%.2f", inventory.totalprofit);
  273.                           printf("\n\nTOTAL ASSETS = $");
  274.                           printf("%.2f", inventory.asset);
  275.                           printf("\n\nNET WORTH    = $");
  276.                           printf("%.2f", inventory.networth);
  277.                           printf("\n\n\n\n\n");
  278.                            
  279.                            
  280.  }
  281.  
  282.  
  283. /*MAIN FUNCTION*/
  284. int main()
  285.  {
  286.     x=0;
  287.        
  288.     /*INITIAL SETUP UPON FIRST USE*/   
  289.     printf("*****\n");
  290.     printf ("SETUP\n");
  291.     printf("*****\n\n");
  292.    
  293.     printf(" ENTER ADMIN ID: ");
  294.     scanf("%s", adminusername);
  295.     printf("\n");
  296.     strlen1=strlen(adminusername);
  297.     printf(" ENTER ADMIN PASSWORD: ");
  298.     scanf("%s", adminpassword);
  299.     printf("\n");
  300.     strlen2=strlen(adminpassword);
  301.     printf(" CONFIRM ADMIN PASSWORD: ");
  302.     scanf("%s", confirmpassword);
  303.    
  304.     while (strlen1 < minlength || strlen2 < minlength || strcmp(adminpassword,confirmpassword) != 0)
  305.      {
  306.         printf("\n\n\n");
  307.         while (strlen1 < minlength)
  308.          {
  309.             printf("    THE ADMIN ID IS TOO SHORT..\n");
  310.             printf("        RE-ENTER: ");
  311.             scanf("%s", adminusername);
  312.             printf("\n\n");
  313.             strlen1=strlen(adminusername);
  314.          }
  315.          
  316.         while (strlen2 < minlength)
  317.          {
  318.             printf("    THE PASSWORD LENGTH IS TOO SHORT..\n");
  319.             printf("        RE-ENTER: ");
  320.             scanf("%s", adminpassword);
  321.             printf("\n\n");
  322.             strlen2=strlen(adminpassword); 
  323.             printf("        ENTER CONFIRMATION PASSWORD: ");
  324.             scanf("%s", confirmpassword);      
  325.          }
  326.        
  327.          
  328.         if (strcmp(adminpassword,confirmpassword) != 0)
  329.          {
  330.             printf("\n\n");
  331.             printf("        THE PASSWORD AND CONFIRMATION PASSWORD DO NOT MATCH..\n\n");
  332.             sleep(2);
  333.             printf("        RE-ENTER PASSWORD: ");
  334.             scanf("%s", adminpassword);
  335.             printf("\n\n");
  336.             strlen2=strlen(adminpassword); 
  337.             printf("        ENTER CONFIRMATION PASSWORD: ");
  338.             scanf("%s", confirmpassword);  
  339.          }
  340.      }
  341.      
  342.      printf("\n\n\n");
  343.      printf("**************\n");
  344.      printf("SETUP COMPLETE\n");
  345.      printf("**************\n\n\n");
  346.      sleep(3);
  347.      printf("This program is optimized for Fullscreen mode.\n    Press 'alt + enter' to go Fullscreen.\n\n\n");
  348.      sleep(2);
  349.      printf("Program will now load. Please be patient..");
  350.      sleep(3);
  351.  
  352.    
  353.    
  354.     /*LOGIN SEGMENT*/
  355.     while (choice != 100)
  356.      {
  357.         for (y=0;y<3000;y++)
  358.          {
  359.           printf("\n\n\n\n\n\n\n\n\n");
  360.          } 
  361.         printf("This program is optimized for Fullscreen mode.\n    Press 'alt + enter' to go Fullscreen.\n\n\n\n");
  362.         printf("************\n");
  363.         printf("   LOGIN\n");
  364.         printf("************\n\n");
  365.        
  366.        
  367.         printf("LOGIN AS: \n");
  368.         printf("\n");
  369.         printf(" 1] EMPLOYEE\n");
  370.         printf(" 2] ADMIN\n\n");
  371.        
  372.         printf(" 100] SHUT DOWN\n\n");
  373.         printf("Choice: ");
  374.         scanf("%d", &choice);
  375.        
  376.         if (choice == 100)
  377.          {
  378.             printf("\n\n\n\n");
  379.             sleep(2);
  380.             printf("Saving Changes.");
  381.             sleep(1);
  382.             printf(".");
  383.             sleep(1);
  384.             printf(".");
  385.             sleep(4);
  386.             printf("\nShutting Down.");
  387.             sleep(2);
  388.             printf(".");
  389.             sleep(2);
  390.             printf(".");
  391.             sleep(2);
  392.             printf(".");
  393.             sleep(3);
  394.             printf("\n");
  395.            
  396.  
  397.          }
  398.  
  399.  
  400.        
  401.         if (choice == 2)
  402.          {
  403.          printf("\n\n\n");
  404.          sleep(1);
  405.          printf("ENTER THE ADMIN PASSWORD TO ACCESS: ");
  406.          scanf("%s", testpassword);
  407.          
  408.          if (strcmp(testpassword,adminpassword) != 0)
  409.           {
  410.             printf("\n\n\n");
  411.             printf("********************\n");
  412.             printf("ADMIN LOGIN DETECTED\n");
  413.             printf("********************\n\n");
  414.                
  415.             printf("now logging attempt");
  416.             sleep(1);
  417.             printf(".");
  418.             sleep(1);
  419.             printf(".");
  420.             sleep(1);
  421.             printf(".\n\n\n");
  422.             sleep(2);
  423.                
  424.             printf("PASSWORD INCORRECT\nresetting..");
  425.             sleep(3);
  426.           }      
  427.          if (strcmp(testpassword,adminpassword) == 0)
  428.           {
  429.          
  430.          
  431.              while (choice != 8)
  432.                   {
  433.                      for (y=0;y<3000;y++)
  434.                       {
  435.                         printf("\n\n\n\n\n\n\n\n\n");
  436.                       }
  437.                      choice=0;
  438.                      printf ("\n\n\n\nADMINISTRATOR MENU\n\n");
  439.          
  440.                      printf (" 1] Display Inventory\n");
  441.                      printf (" 2] Edit Inventory\n");
  442.                      printf (" 3] Add Employee Record\n");
  443.                      printf (" 4] Remove Employee Record\n");
  444.                      printf (" 5] List Employee Records\n");
  445.                      printf (" 6] Change Admin ID\n");
  446.                      printf (" 7] Change Admin password\n");
  447.                      printf (" 8] Exit Admin Mode\n\n");
  448.          
  449.                      printf ("Choice: ");
  450.                      scanf ("%d", &choice);
  451.                      printf ("\n\n");
  452.                        
  453.                        
  454.                        
  455.                        
  456.                      if (choice == 1)
  457.                       {
  458.                         choice=0;
  459.                         if(itemCNT == 0)
  460.                          {
  461.                           printf("\n\n                                                                      No items to display...");
  462.                           sleep(3);
  463.                          }
  464.                         else
  465.                          {
  466.                           inventoryprint();
  467.                           printf("\n\n\n\n\n");
  468.                          
  469.                            printf("\n\n\n\n\n\n\n\n\n\n\nEnter anything to exit..");
  470.                            char input[1];
  471.                            scanf("%s",input);
  472.                            if (strcmp(input,"") == 0)
  473.                            break;  
  474.                          }
  475.                       }  
  476.                      
  477.                      
  478.                      
  479.                      if (choice == 2)
  480.                       {
  481.                         choice = 0;
  482.                         while (choice != 5)
  483.                          {
  484.                                 inventoryprint();
  485.                                 printf("\n\n\n\n");
  486.                                 printf("What would you like to do: \n\n");
  487.                                 printf(" 1] Add item\n");
  488.                                 printf(" 2] Remove item\n");
  489.                                 printf(" 3] Edit an item\n");
  490.                                 printf(" 4] Change Tax Rate\n");
  491.                                 printf(" 5] Exit\n\n");
  492.                                
  493.                                 printf("Choice: ");
  494.                                 scanf("%d", &choice);
  495.                                 printf("\n\n\n");
  496.                                
  497.                                 /*TO EXIT*/
  498.                                 if (choice == 5)
  499.                                  {
  500.                                     choice = 0;
  501.                                     break;
  502.                                  }
  503.                                
  504.                                 if (choice == 4)
  505.                                  {
  506.                                     printf("\n\n");
  507.                                     printf("Enter new tax rate (eg: '0.165'): ");
  508.                                     scanf("%f", &pos.tax);
  509.                                     printf("\nSUCCESSFUL");
  510.                                     sleep(2);
  511.                                  }
  512.                                
  513.                                 /*TO ADD ITEM*/
  514.                                 if (choice == 1)
  515.                                  {
  516.                                     additem();
  517.                                  }
  518.                                  
  519.                                  
  520.                                 /*TO REMOVE ITEM*/
  521.                                 if (choice == 2)
  522.                                  {
  523.                                    while (choice != 3)
  524.                                     {
  525.                                      
  526.                                      printf("What would you like to do: \n\n");
  527.                                    
  528.                                      printf(" 1] Lessen Item Quantity\n");
  529.                                      printf(" 2] Complete Item Removal\n");
  530.                                      printf(" 3] Exit\n\n");
  531.                                      
  532.                                      printf ("Choice: ");
  533.                                      scanf("%d", &choice);
  534.                                      
  535.                                      
  536.                                      
  537.                                      
  538.                                      
  539.                                      
  540.                                      
  541.                                      /*TO EDIT ITEM*/
  542.                                      if (choice == 3)
  543.                                      {
  544.                                       choice = 0;
  545.                                       break;
  546.                                      }
  547.                                      else
  548.                                       {
  549.    
  550.                                           for (y=0;y<3000;y++)
  551.                                             {
  552.                                                 printf("\n\n\n\n\n\n\n\n\n");
  553.                                             }
  554.                          
  555.                                          
  556.                                          
  557.                                          
  558.                                          
  559.                                          
  560.                                           /*TO LESSEN ITEM QUANTITY*/
  561.                                           if (choice == 1)
  562.                                            {
  563.                                                
  564.                                               while(choice != 2)
  565.                                                {
  566.                                                 inventoryprint();  
  567.                                                  
  568.                                                  
  569.                                                   if (choice == 1)
  570.                                                    {
  571.                                                     while(choice == 1)
  572.                                                      {
  573.                                                        
  574.                                                         printf("ENTER ID# OF THE ITEM TO LESSEN THE QUANTITY OF: ");
  575.                                                         scanf("%d", &b);
  576.                                                        
  577.                                                         for(a=0;a<x;a++)
  578.                                                          {
  579.                                                             if(a == b)
  580.                                                              {
  581.                                                                 admit = 1;
  582.                                                                 y=a;
  583.                                                                 break; 
  584.                                                              }
  585.                                                             else
  586.                                                                 admit = 0;
  587.                                                          }
  588.                                                          
  589.                                                         if (admit == 1)
  590.                                                          {
  591.                                                            
  592.                                                             inventoryprint();
  593.                                                            
  594.                                                             printf("\n\n\n\n");
  595.                                                             printf("Lower the stock quantity by: ");
  596.                                                             scanf("%f", &floatcontainer);
  597.                                                             printf("\n\n\n");
  598.                                                             printf("Pass this item as spoilt: \n\n");
  599.                                                             printf(" 1] Yes\n");
  600.                                                             printf(" 2] No\n\n");
  601.                                                            
  602.                                                             printf("Choice: ");
  603.                                                             scanf("%d", &choice);
  604.                                                             if (choice==1)
  605.                                                             {
  606.                                                              inventory.spoiltquantity[a] = inventory.spoiltquantity[a] + floatcontainer;           
  607.                                                             }
  608.                                                             inventory.stock[a] = inventory.stock[a] - floatcontainer;
  609.                                                             inventory.profit_loss[a] = ((inventory.sp[a]-inventory.bp[a])*inventory.sold[a]) - inventory.spoiltloss[a];
  610.                                                            
  611.                                                            
  612.                                                             printf("\n\n\n\n\n");
  613.                                                             printf("OK.\n");
  614.                                                             sleep(3);
  615.                                                            
  616.    
  617.                                                          }
  618.                                                         else
  619.                                                          {
  620.                                                             printf("\n\n\n\n");
  621.                                                             printf("ITEM NOT FOUND..");
  622.                                                             sleep(3);
  623.                                                             printf("\n\n\n");
  624.                                                          }
  625.                                                          
  626.                                                         printf("\n\n\n\n\n");
  627.                                                         printf("Continue? Enter '1' for yes and '2' for no: ");
  628.                                                         scanf("%d", &choice);                                
  629.                                                        
  630.                                                         printf("\n\n\n\n\n\n\n\n\n");
  631.    
  632.                                                         if (choice == 2)
  633.                                                          {
  634.                                                             printf("resetting..\n\n\n\n\n");
  635.                                                             sleep(2);                                                      
  636.                                                             break;
  637.                                                          }
  638.                                                      }
  639.                                                    }
  640.                                                  
  641.                                                  
  642.        
  643.                                                    
  644.                                                    
  645.                                              if (choice == 2)
  646.                                               {
  647.                                                 choice = 0;
  648.                                                 break;
  649.                                               }    
  650.        
  651.                                                
  652.                                             }
  653.    
  654.                                           }
  655.                                          
  656.                                          
  657.                                          
  658.                                          
  659.                                          
  660.                                          
  661.                                           /*TO WIPE ITEM FROM DATABASE*/
  662.                                           if (choice == 2)
  663.                                                {
  664.                                                     inventoryprint();
  665.                                                     choice = 0;
  666.                                                     while (choice != 2)
  667.                                                      {
  668.                                                         printf("ENTER THE ID# OF THE ITEM TO REMOVE: ");
  669.                                                         scanf("%d", &b);
  670.                                                        
  671.                                                         for(a=0;a<x;a++)
  672.                                                          {
  673.                                                             if(a == b)
  674.                                                              {
  675.                                                                 admit = 1;
  676.                                                                 break; 
  677.                                                              }
  678.                                                             else
  679.                                                                 admit = 0;
  680.                                                          }
  681.                                                          
  682.                                                         if (admit == 1)
  683.                                                          {
  684.            
  685.                                                             inventory.stock[a]=0;
  686.                                                             inventory.bp[a]=0;
  687.                                                             inventory.sp[a]=0;
  688.                                                             inventory.sold[a]=0;
  689.                                                             inventory.spoiltquantity[a]=0;
  690.                                                             strcpy(inventory.itemname[a],"\0");
  691.                                                             inventory.spoiltloss[a]=0;
  692.                                                             inventory.profit_loss[a]=0;
  693.                                                            
  694.                                                             /*LOOP RESULTING THE THE REMOVAL OF THE ITEM RECORD*/
  695.                                                             for (b=a;b<y;b++)
  696.                                                              {
  697.                                                                 strcpy(inventory.itemname[b],"\n");
  698.                                                                 inventory.bp[b] = inventory.bp[b+1];
  699.                                                                 inventory.sp[b] = inventory.sp[b+1];
  700.                                                                 inventory.sold[b] = inventory.sold[b+1];
  701.                                                                 inventory.spoiltquantity[b] = inventory.spoiltquantity[b+1];
  702.                                                                 inventory.spoiltloss[b] = inventory.spoiltloss[b+1];
  703.                                                                 inventory.profit_loss[b] = inventory.profit_loss[b+1];
  704.                                                              }
  705.                                                             itemCNT--;
  706.                                                             printf("\n\n\n\n\n");
  707.                                                             printf("ITEM SUCCESSFULLY REMOVED.\n");
  708.                                                             sleep(3);
  709.                                                
  710.                                                             for (y=0;y<3000;y++)
  711.                                                              {
  712.                                                                 printf("\n\n\n\n\n\n\n\n\n");
  713.                                                              } 
  714.                                                              
  715.                                                            
  716.                                                          }
  717.                                                          else
  718.                                                           {
  719.                                                             printf("\n\n\n\n");
  720.                                                             printf("ITEM NOT FOUND..");
  721.                                                             sleep(3);
  722.                                                           }
  723.                                                          
  724.                                                          
  725.                                                             printf("\n\n\n\n\n");
  726.                                                             printf("Continue? Enter '1' for yes and '2' for no: ");
  727.                                                             scanf("%d", &choice);                                
  728.                                                            
  729.                                                             printf("\n\n\n\n\n\n\n\n\n");
  730.        
  731.                                                             if (choice == 2)
  732.                                                              {
  733.                                                                 choice = 0;
  734.                                                                 printf("resetting..\n");
  735.                                                                 sleep(2);                                                      
  736.                                                                 break;
  737.                                                              }
  738.                                                        }  
  739.    
  740.                                                }             
  741.  
  742.                                       }
  743.                                           }
  744.                
  745.                                  }
  746.                                
  747.                                
  748.                                
  749.                                 /*TO EDIT ITEM*/
  750.                                 if (choice == 3)
  751.                                  {
  752.                                     choice = 0;
  753.                                     while (choice != 3)
  754.                                     {
  755.                                      
  756.                                         printf("\n\n\n");
  757.                                         printf("Edit item by: \n\n");
  758.                                         printf(" 1] Name\n");
  759.                                         printf(" 2] ID#\n");
  760.                                         printf(" 3] Exit\n\n");
  761.                                        
  762.                                         printf("Choice: ");
  763.                                         scanf("%d", &choice);
  764.                                        
  765.                                         /*TO EXIT THE LOOP*/
  766.                                         if (choice == 3)
  767.                                          {
  768.                                             choice = 0;
  769.                                             break;
  770.                                          }
  771.                                        
  772.                                         /*EDITING ITEM BY NAME*/
  773.                                         if (choice == 1)
  774.                                          {
  775.                                           printf("ENTER THE NAME OF THE ITEM: ");
  776.                                           scanf("%s", container);
  777.                                          
  778.                                           for (a=0;a<itemCNT;a++)
  779.                                            {
  780.                                             if (strcmp(container,inventory.itemname[a]) == 0)
  781.                                              {
  782.                                                 admit = 1;
  783.                                                 break;
  784.                                              }
  785.                                             else
  786.                                              admit = 0;
  787.                                            }
  788.                                            
  789.                                           if (admit == 1)
  790.                                            {
  791.                                             edititem();
  792.                                            }
  793.                                           else
  794.                                            {
  795.                                             printf("ITEM NOT FOUND...");
  796.                                             sleep(3);
  797.                                             printf("\n\n\n\n\n\n\n");
  798.                                            }
  799.                                          
  800.                                          }
  801.                                          
  802.                                          
  803.                                          
  804.                                         /*EDITING ITEM BY ID#*/
  805.                                         if (choice == 2)
  806.                                          {
  807.                                           printf("ENTER THE ID# OF THE ITEM: ");
  808.                                           scanf("%d", &idno);
  809.                                          
  810.                                           for (a=0;a<itemCNT;a++)
  811.                                            {
  812.                                             if (idno==a)
  813.                                              {
  814.                                                 admit = 1;
  815.                                                 break;
  816.                                              }
  817.                                             else
  818.                                              admit = 0;
  819.                                            }
  820.                                            
  821.                                            if (admit == 1)
  822.                                             {
  823.                                              edititem();
  824.                                             }
  825.                                            else
  826.                                             {
  827.                                                 printf("ITEM NOT FOUND...");
  828.                                                 sleep(3);
  829.                                                 printf("\n\n\n\n\n\n\n");
  830.                                             }
  831.                                            
  832.                                            
  833.                                          }
  834.                                        
  835.                                     }
  836.                                  }
  837.                          }
  838.                       }
  839.                      
  840.                      
  841.                      
  842.                      
  843.                      
  844.                      if (choice == 3)
  845.                       {
  846.                         if (workerCNT == 99)
  847.                          {
  848.                             printf("EMPLOYEE DATABASE IS FULL, DELETE A RECORD TO CONTINUE.");
  849.                             sleep(2);
  850.                             printf("resetting..");
  851.                             sleep(3);
  852.                             break;
  853.                          }
  854.                             printf("\n\n");
  855.                             printf("ENTER EMPLOYEE ID: ");
  856.                             scanf("%s", container);
  857.                             for (x=0;x<workerCNT;x++)
  858.                              {
  859.                                 if (strcmp(container,record.username[x]) == 0)
  860.                                  {
  861.                                     admit =1;
  862.                                     break;
  863.                                  }
  864.                                 else
  865.                                  admit=0;
  866.                              }
  867.                             if (admit == 1)
  868.                              {
  869.                                 printf("THAT ID IS ALREADY USED, CANNOT CREATE DUPLICATE IDENTIIERS..");
  870.                                 sleep(2);
  871.                                 printf("\n\n");
  872.                                 printf("TERMINATING..");
  873.                                 sleep(2);
  874.                                 break;
  875.                              }
  876.                             else
  877.                              strcpy(record.username[workerCNT],container);
  878.                              
  879.                             printf("ENTER EMPLOYEE PASSWORD: ");
  880.                             scanf("%s", record.password[workerCNT]);
  881.                             while (strlen(record.password[workerCNT]) > 8)
  882.                              {
  883.                                 printf("\n\n");
  884.                                 printf("PASSWORD EXCEEDES MAX, ENTER SHORTER PASSWORD: ");
  885.                                 scanf("%s", record.password[workerCNT]);
  886.                              }
  887.                             printf("\n\n");
  888.                             printf(" ENTER EMPLOYEE FIRST NAME: ");
  889.                             scanf("%s", record.fname[workerCNT]);
  890.                             printf("\n");
  891.                             printf(" ENTER EMPLOYEE MIDDLE NAME: ");
  892.                             scanf("%s", record.mname[workerCNT]);
  893.                             printf("\n");
  894.                             printf(" ENTER EMPLOYEE LAST NAME: ");
  895.                             scanf("%s", record.lname[workerCNT]);
  896.                             printf("\n\n");
  897.                             printf(" ENTER EMPLOYEE D.O.B (dd/mm/yyyy): ");
  898.                             scanf("%s", record.dob[workerCNT]);
  899.                             printf("\n WHAT IS THE EMPLOYEE's GENDER: \n");
  900.                             printf("  1] MALE\n");
  901.                             printf("  2] FEMALE\n\n");
  902.                             printf(" Choice: ");
  903.                             scanf("%d", &record.gender);
  904.                            
  905.                             if (record.gender != 2)
  906.                              {
  907.                                 record.male[workerCNT] = 1;
  908.                                 record.female[workerCNT] = 0;
  909.                              }
  910.                             if (record.gender == 2)
  911.                              {
  912.                                 record.male[workerCNT] = 0;
  913.                                 record.female[workerCNT] = 1;
  914.                              }
  915.                             //<-- WORK HERE
  916.                             //<-- WORK HEEE
  917.                             //<-- WORK HEEE
  918.        
  919.                             workerCNT++;
  920.                             printf("\n\n\n\n");
  921.                             printf("EMPLOYEE SUCCESSFULLY ADDED.");
  922.                             sleep(3);
  923.                        
  924.                       }
  925.                      
  926.                      
  927.                      
  928.                      if (choice == 4)
  929.                       {
  930.                         printf("\n\n");
  931.                         printf("ENTER EMPLOYEE ID TO REMOVE: ");
  932.                         scanf("%s", record.deleteID);
  933.                        
  934.                         for (x=0;x<100;x++)
  935.                          {
  936.                             if (strcmp(record.deleteID,record.username[x]) == 0)
  937.                              {
  938.                                 admit = 1;
  939.                                 y=x;
  940.                                 break;
  941.                              }
  942.                             else
  943.                              {
  944.                                 admit = 0;
  945.                              }
  946.                          }
  947.                          
  948.                         if (admit == 1)
  949.                          {
  950.                                     strcpy(record.username[x],"\0");
  951.                                     strcpy(record.password[x],"\0");
  952.                                     strcpy(record.fname[x],"\0");
  953.                                     strcpy(record.mname[x],"\0");
  954.                                     strcpy(record.lname[x],"\0");
  955.                                     strcpy(record.dob[x],"\0");
  956.  
  957.                                  
  958.                                   for (x=y;x<workerCNT-1;x++)
  959.                                    {
  960.                                     strcpy(record.username[x],record.username[x+1]);
  961.                                     strcpy(record.password[x],record.password[x+1]);
  962.                                     strcpy(record.fname[x],record.fname[x+1]);
  963.                                     strcpy(record.mname[x],record.mname[x+1]);
  964.                                     strcpy(record.lname[x],record.lname[x+1]);
  965.                                     strcpy(record.dob[x],record.dob[x+1]);
  966.                                     record.male[x] = record.male[x+1];
  967.                                     record.female[x] = record.female[x+1];
  968.                                    }//<-- WORk ON HERE< LOOP TO REMOVE EMPLOYEE
  969.        
  970.                                   printf("*****************************\n");
  971.                                   printf("EMPLOYEE SUCCESSFULLY REMOVED\n");
  972.                                   printf("*****************************\n\n");
  973.                                   workerCNT--;
  974.                                   sleep(3);
  975.                          }
  976.                         else
  977.                          {
  978.                             printf("ID WAS NOT FOUND IN THE DATABASE.\nresetting..");
  979.                             sleep(3);
  980.                          }
  981.                       }
  982.                      
  983.                      
  984.                      
  985.                      
  986.                      
  987.                      /*TO LIST EMPLOYEE RECORDS*/
  988.                      if (choice == 5)
  989.                       {
  990.                         while (choice != 3)
  991.                          {
  992.                            
  993.                             printf("\n\n\n");
  994.                             printf("***********************************************************************************************************************************************************************\n");
  995.                             printf("|   LIST#       FIRSTNAME               MIDDLENAME                LASTNAME             PASSWORD                 DOB         MALE     FEMALE              ID   |\n");
  996.                             printf("***********************************************************************************************************************************************************************\n\n");
  997.                            
  998.                             for (x=0;x<workerCNT;x++)
  999.                                 {
  1000.                                     printf("%6d", x);
  1001.                                     printf("%19s", record.fname[x]);
  1002.                                     printf("%25s", record.mname[x]);
  1003.                                     printf("%24s", record.lname[x]);
  1004.                                     printf("%21s", record.password[x]);
  1005.                                     printf("%20s", record.dob[x]);
  1006.                                     printf("%17d", record.male[x]);
  1007.                                     printf("%11d", record.female[x]);
  1008.                                     printf("%20s", record.username[x]);
  1009.                                     printf("\n\n");
  1010.                                  
  1011.                                 }
  1012.                            
  1013.                            printf("\n\n\n\n\n\n\n\n");
  1014.                            printf("WHAT WOULD YOU LIKE TO DO: \n\n");
  1015.                            printf(" 1] ADD EMPLOYEE\n");
  1016.                            printf(" 2] REMOVE EMPLOYEE\n");
  1017.                            printf(" 3] EXIT\n\n");
  1018.                            
  1019.                            printf("Choice: ");
  1020.                            scanf("%d", &choice);
  1021.                            
  1022.                            
  1023.                            
  1024.                              
  1025.                              
  1026.                              
  1027.                              /*IF DATABASE IS FULL USER HAS TO DELETE RECORDS TO PROCEED*/
  1028.                              if (choice == 1)
  1029.                               {
  1030.                                 if (workerCNT == 99)
  1031.                                  {
  1032.                                     printf("EMPLOYEE DATABASE IS FULL, DELETE A RECORD TO CONTINUE.");
  1033.                                     sleep(2);
  1034.                                     printf("resetting..");
  1035.                                     sleep(3);
  1036.                                     break;
  1037.                                  }
  1038.                                     printf("\n\n");
  1039.                                     printf("ENTER EMPLOYEE ID: ");
  1040.                                     scanf("%s", container);
  1041.                                     for (x=0;x<workerCNT;x++)
  1042.                                      {
  1043.                                         if (strcmp(container,record.username[x]) == 0)
  1044.                                          {
  1045.                                             admit =1;
  1046.                                             break;
  1047.                                          }
  1048.                                         else
  1049.                                          admit=0;
  1050.                                      }
  1051.                                     if (admit == 1)
  1052.                                      {
  1053.                                         printf("THAT ID IS ALREADY USED, CANNOT CREATE DUPLICATE IDENTIIERS..");
  1054.                                         sleep(2);
  1055.                                         printf("\n\n");
  1056.                                         printf("TERMINATING..");
  1057.                                         sleep(2);
  1058.                                         break;
  1059.                                      }
  1060.                                     else
  1061.                                      strcpy(record.username[workerCNT],container);
  1062.                                      
  1063.                                     printf("ENTER EMPLOYEE PASSWORD: ");
  1064.                                     scanf("%s", record.password[workerCNT]);
  1065.                                     printf("\n\n");
  1066.                                     printf(" ENTER EMPLOYEE FIRST NAME: ");
  1067.                                     scanf("%s", record.fname[workerCNT]);
  1068.                                     printf("\n");
  1069.                                     printf(" ENTER EMPLOYEE MIDDLE NAME: ");
  1070.                                     scanf("%s", record.mname[workerCNT]);
  1071.                                     printf("\n");
  1072.                                     printf(" ENTER EMPLOYEE LAST NAME: ");
  1073.                                     scanf("%s", record.lname[workerCNT]);
  1074.                                     printf("\n\n");
  1075.                                     printf(" ENTER EMPLOYEE D.O.B (dd/mm/yyyy): ");
  1076.                                     scanf("%s", record.dob[workerCNT]);
  1077.                                     printf("\n WHAT IS THE EMPLOYEE's GENDER: \n");
  1078.                                     printf("  1] MALE\n");
  1079.                                     printf("  2] FEMALE\n\n");
  1080.                                     printf(" Choice: ");
  1081.                                     scanf("%d", &record.gender);
  1082.                                    
  1083.                                     if (record.gender != 2)
  1084.                                      {
  1085.                                         record.male[workerCNT] = 1;
  1086.                                         record.female[workerCNT] = 0;
  1087.                                      }
  1088.                                     if (record.gender == 2)
  1089.                                      {
  1090.                                         record.male[workerCNT] = 0;
  1091.                                         record.female[workerCNT] = 1;
  1092.                                      }
  1093.  
  1094.  
  1095.  
  1096.                
  1097.                                     workerCNT++;
  1098.                                     printf("\n\n\n\n");
  1099.                                     printf("EMPLOYEE SUCCESSFULLY ADDED.");
  1100.                                     sleep(3);
  1101.                                
  1102.                               }
  1103.                              
  1104.                              
  1105.                              
  1106.                              if (choice == 2)
  1107.                               {
  1108.                                 printf("\n\n");
  1109.                                 printf("ENTER EMPLOYEE ID TO REMOVE: ");
  1110.                                 scanf("%s", record.deleteID);
  1111.                                
  1112.                                 for (x=0;x<100;x++)
  1113.                                  {
  1114.                                     if (strcmp(record.deleteID,record.username[x]) == 0)
  1115.                                      {
  1116.                                         admit = 1;
  1117.                                         y=x;
  1118.                                         break;
  1119.                                      }
  1120.                                     else
  1121.                                      {
  1122.                                         admit = 0;
  1123.                                      }
  1124.                                  }
  1125.                                  
  1126.                                 if (admit == 1)
  1127.                                  {
  1128.                                     strcpy(record.username[x],"\0");
  1129.                                     strcpy(record.password[x],"\0");
  1130.                                     strcpy(record.fname[x],"\0");
  1131.                                     strcpy(record.mname[x],"\0");
  1132.                                     strcpy(record.lname[x],"\0");
  1133.                                     strcpy(record.dob[x],"\0");
  1134.  
  1135.                                  
  1136.                                   for (x=y;x<workerCNT;x++)
  1137.                                    {
  1138.                                     strcpy(record.username[x],record.username[x+1]);
  1139.                                     strcpy(record.password[x],record.password[x+1]);
  1140.                                     strcpy(record.fname[x],record.fname[x+1]);
  1141.                                     strcpy(record.mname[x],record.mname[x+1]);
  1142.                                     strcpy(record.lname[x],record.lname[x+1]);
  1143.                                     strcpy(record.dob[x],record.dob[x+1]);
  1144.                                     record.male[x] = record.male[x+1];
  1145.                                     record.female[x] = record.female[x+1];
  1146.                                    }//<-- LOOP TO REMOVE EMPLOYEE
  1147.        
  1148.                                   printf("*****************************\n");
  1149.                                   printf("EMPLOYEE SUCCESSFULLY REMOVED\n");
  1150.                                   printf("*****************************\n\n");
  1151.                                   workerCNT--;
  1152.                                   sleep(3);
  1153.                                  }
  1154.                                 else
  1155.                                  {
  1156.                                     printf("ID WAS NOT FOUND IN THE DATABASE.\nresetting..");
  1157.                                     sleep(3);
  1158.                                  }
  1159.                               }
  1160.                              
  1161.                               if (choice == 3)
  1162.                                break;
  1163.                            
  1164.                            
  1165.                          }
  1166.                       }
  1167.                      
  1168.                      
  1169.                      
  1170.                      if (choice == 6)
  1171.                       {
  1172.                         printf("\n\n");
  1173.                         printf("ENTER NEW ADMIN ID: ");
  1174.                         scanf("%s", adminusername);
  1175.                         printf("\n\nSUCCESSFUL");
  1176.                         sleep(2);
  1177.                       }
  1178.                      
  1179.                      
  1180.                      
  1181.                      if (choice == 7)
  1182.                       {
  1183.                         printf("ENTER CURRENT ADMIN PASSWORD: ");
  1184.                         scanf("%s", testpassword);
  1185.                        
  1186.                         printf("\n\n");
  1187.                         if (strcmp(testpassword,password) == 0)
  1188.                          {
  1189.                             printf(" ENTER NEW ADMIN PASSSWORD: ");
  1190.                             scanf("%s", adminpassword);
  1191.                             printf("\n");
  1192.                             strlen2=strlen(adminpassword);
  1193.                             printf(" CONFIRM ADMIN PASSWORD: ");
  1194.                             scanf("%s", confirmpassword);
  1195.                            
  1196.                             while (strlen1 < minlength || strlen2 < minlength || strcmp(adminpassword,confirmpassword) != 0)
  1197.                              {
  1198.                                 printf("\n\n\n");
  1199.                                 while (strlen1 < minlength)
  1200.                                  {
  1201.                                     printf("    THE ADMIN ID IS TOO SHORT..\n");
  1202.                                     printf("        RE-ENTER: ");
  1203.                                     scanf("%s", adminusername);
  1204.                                     printf("\n\n");
  1205.                                     strlen1=strlen(adminusername);
  1206.                                  }
  1207.                                  
  1208.                                 while (strlen2 < minlength)
  1209.                                  {
  1210.                                     printf("    THE PASSWORD LENGTH IS TOO SHORT..\n");
  1211.                                     printf("        RE-ENTER: ");
  1212.                                     scanf("%s", adminpassword);
  1213.                                     printf("\n\n");
  1214.                                     strlen2=strlen(adminpassword); 
  1215.                                     printf("        ENTER CONFIRMATION PASSWORD: ");
  1216.                                     scanf("%s", confirmpassword);      
  1217.                                  }
  1218.                                
  1219.                                  
  1220.                                 if (strcmp(adminpassword,confirmpassword) != 0)
  1221.                                  {
  1222.                                     printf("\n\n");
  1223.                                     printf("        THE PASSWORD AND CONFIRMATION PASSWORD DO NOT MATCH..\n");
  1224.                                     sleep(2);
  1225.                                     printf("        RE-ENTER PASSWORD: ");
  1226.                                     scanf("%s", adminpassword);
  1227.                                     printf("\n\n");
  1228.                                     strlen2=strlen(adminpassword); 
  1229.                                     printf("        ENTER CONFIRMATION PASSWORD: ");
  1230.                                     scanf("%s", confirmpassword);  
  1231.                                  }
  1232.                              }
  1233.                              
  1234.                              printf("\n\n\n");
  1235.                              printf("*****************************\n");
  1236.                              printf("PASSWORD CHANGED SUCCESSFULLY\n");
  1237.                              printf("*****************************\n\n\n");
  1238.                              sleep(4);
  1239.                          }
  1240.                       }
  1241.                      
  1242.                   }
  1243.           }
  1244.          
  1245.  
  1246.          }
  1247.  
  1248.          
  1249.          if (choice == 1)
  1250.           {
  1251.             printf("\n\n\n\n");
  1252.             printf("ENTER ID: ");
  1253.             scanf("%s", username);
  1254.  
  1255.            
  1256.             for(x=0;x<100;x++)
  1257.              {
  1258.                 if (strcmp(username,record.username[x]) == 0)
  1259.                  {
  1260.                     admit = 1;
  1261.                     currentlogin = x;
  1262.                     break;
  1263.                  }
  1264.                 else
  1265.                  admit = 0;  
  1266.              }
  1267.          
  1268.             if (admit==0)
  1269.              {
  1270.                  printf("\n\n\n");
  1271.                  printf("ID NOT FOUND IN THE DATABASE..\n");
  1272.                  sleep(3);
  1273.                  printf("resetting..");
  1274.                  sleep(3);
  1275.                  
  1276.                  
  1277.              }
  1278.              
  1279.             if (admit == 1)
  1280.              {
  1281.                 printf("ENTER PASSWORD: ");
  1282.                 scanf("%s", testpassword);
  1283.                
  1284.                 if (strcmp(testpassword,record.password[currentlogin]) == 0)
  1285.                  {
  1286.                     printf("\n\n\n");
  1287.                     printf ("****************\n");
  1288.                     printf ("LOGIN SUCCESSFUL\n");
  1289.                     printf ("****************\n\n");
  1290.                     sleep(3);
  1291.                     for (y=0;y<3000;y++)
  1292.                      {
  1293.                       printf("\n\n\n\n\n\n\n\n\n");
  1294.                      }
  1295.                      
  1296.                      
  1297.                      
  1298.                      
  1299.                      
  1300.                      
  1301.                      
  1302.                      
  1303.                      
  1304.                      
  1305.                      
  1306.                      
  1307.                      
  1308.                      
  1309.                      
  1310.                      
  1311.                      
  1312.                      
  1313.                      
  1314.                      
  1315.                      
  1316.                      
  1317.                      
  1318.                     while (choice != 7)
  1319.                      {
  1320.                          choice = 0;
  1321.                          printf(" *****************\n");
  1322.                          printf(" CHENG'S INVENTORY\n");
  1323.                          printf(" *****************\n\n");
  1324.                          
  1325.                          printf ("Logged in as: ");
  1326.                          printf ("%s", record.username[currentlogin]);
  1327.                          printf("\n");
  1328.                          printf("Enter the number beside the desired choice\n\n");
  1329.                
  1330.                          printf("1] Display Inventory\n");
  1331.                          printf("2] Add item in inventory\n");
  1332.                          printf("3] Remove item in inventory\n");
  1333.                          printf("4] Edit item in inventory\n");
  1334.                          printf("5] Item Search\n");
  1335.                          printf("6] Boot POS\n");
  1336.                          printf("7] Save changes and Log Off\n\n");
  1337.                
  1338.                          printf("Choice: ");
  1339.                          scanf("%d", &choice);
  1340.                          printf("\n\n\n\n\n\n");
  1341.                          
  1342.                          /*Display Inventory*/
  1343.                          if (choice == 1)
  1344.                           {
  1345.                           choice=0;
  1346.                           if(itemCNT == 0)
  1347.                            {
  1348.                             printf("\n\n                                                                    No items to display...");
  1349.                             sleep(3);
  1350.                            }
  1351.                           else
  1352.                            {
  1353.  
  1354.                             printf("\n\n\n\n\n");
  1355.                             inventoryprint();              
  1356.                            }
  1357.                          }
  1358.                          
  1359.                          /*Add item in inventory*/
  1360.                          if (choice == 2)
  1361.                           {
  1362.                             additem();     
  1363.                           }
  1364.                            
  1365.                            
  1366.                            
  1367.                            
  1368.                            
  1369.                          /*Remove item in inventory*/    
  1370.                          if (choice == 3)
  1371.                           {
  1372.                            choice = 0;
  1373.                            while (choice != 3)
  1374.                             {
  1375.                              
  1376.                              printf("What would you like to do: \n\n");
  1377.                            
  1378.                              printf(" 1] Lessen Item Quantity\n");
  1379.                              printf(" 2] Complete Item Removal\n");
  1380.                              printf(" 3] Exit\n\n");
  1381.                              
  1382.                              printf ("Choice: ");
  1383.                              scanf("%d", &choice);
  1384.                              
  1385.                              
  1386.                              
  1387.                              
  1388.                              
  1389.                              
  1390.                              
  1391.                              
  1392.                              if (choice == 3)
  1393.                               break;
  1394.                              else
  1395.                               {
  1396.                                 printf("Contact the administrator in order to continue.\n\n");
  1397.                                 printf(" ENTER ADMINISTRATOR PASSWORD: ");
  1398.                                 scanf("%s", testpassword);
  1399.                                
  1400.                                 if (strcmp(testpassword,adminpassword) == 0)
  1401.                                  {
  1402.                                       for (y=0;y<3000;y++)
  1403.                                         {
  1404.                                             printf("\n\n\n\n\n\n\n\n\n");
  1405.                                         }
  1406.                      
  1407.                                       printf("\n");
  1408.                                       printf("SUCCESSFUL");
  1409.                                       printf("\n\n\n\n\n");
  1410.                                      
  1411.                                      
  1412.                                      
  1413.                                      
  1414.                                      
  1415.                                      
  1416.                                       if (choice == 1)
  1417.                                        {
  1418.                                           while(choice != 2)
  1419.                                            {
  1420.                                             inventoryprint();
  1421.                                               for (a=0;a<itemCNT;a++)
  1422.                                                {
  1423.                                                     inventory.totalprofit = inventory.totalprofit + inventory.profit_loss[a];
  1424.                                                     inventory.asset = inventory.asset + (inventory.bp[a]*inventory.stock[a]);  
  1425.                                                }
  1426.                                               inventory.networth = inventory.networth + (inventory.asset + inventory.totalprofit);
  1427.                                               printf("\n\n\n\nTOTAL PROFIT = $");
  1428.                                               printf("%.2f", inventory.totalprofit);
  1429.                                               printf("\n\nTOTAL ASSETS = $");
  1430.                                               printf("%.2f", inventory.asset);
  1431.                                               printf("\n\nNET WORTH    = $");
  1432.                                               printf("%.2f", inventory.networth);
  1433.                                               printf("\n\n\n\n\n");    
  1434.                                              
  1435.                                              
  1436.                                               if (choice == 1)
  1437.                                                {
  1438.                                                 while(choice == 1)
  1439.                                                  {
  1440.                                                    
  1441.                                                     printf("ENTER ID# OF THE ITEM TO LESSEN THE QUANTITY OF: ");
  1442.                                                     scanf("%d", &b);
  1443.                                                    
  1444.                                                     for(a=0;a<x;a++)
  1445.                                                      {
  1446.                                                         if(a == b)
  1447.                                                          {
  1448.                                                             admit = 1;
  1449.                                                             y=a;
  1450.                                                             break; 
  1451.                                                          }
  1452.                                                         else
  1453.                                                             admit = 0;
  1454.                                                      }
  1455.                                                      
  1456.                                                     if (admit == 1)
  1457.                                                      {
  1458.                                                        
  1459.                                                         inventoryprint();
  1460.                                                        
  1461.                                                         printf("\n\n\n\n");
  1462.                                                         printf("Lower the stock quantity by: ");
  1463.                                                         scanf("%f", &floatcontainer);
  1464.                                                         printf("\n\n\n");
  1465.                                                         printf("Paass this item as sopilt: \n\n");
  1466.                                                         printf(" 1] Yes\n");
  1467.                                                         printf(" 2] No\n\n");
  1468.                                                        
  1469.                                                         printf("Choice: ");
  1470.                                                         scanf("%d", &choice);
  1471.                                                         if (choice==1)
  1472.                                                         {
  1473.                                                          inventory.spoiltquantity[a] = inventory.spoiltquantity[a] + floatcontainer;
  1474.                                                          }
  1475.                                                         inventory.stock[a] = inventory.stock[a] - floatcontainer;
  1476.                                                         inventory.profit_loss[a] = ((inventory.sp[a]-inventory.bp[a])*inventory.sold[a]) - inventory.spoiltloss[a];
  1477.                                                        
  1478.                                                        
  1479.                                                         printf("\n\n\n\n\n");
  1480.                                                         printf("OK.\n");
  1481.                                                         sleep(3);
  1482.                                                        
  1483.  
  1484.                                                      }
  1485.                                                     else
  1486.                                                      {
  1487.                                                         printf("\n\n\n\n");
  1488.                                                         printf("ITEM NOT FOUND..");
  1489.                                                         sleep(3);
  1490.                                                         printf("\n\n\n");
  1491.                                                      }
  1492.                                                      
  1493.                                                     printf("\n\n\n\n\n");
  1494.                                                     printf("Continue? Enter '1' for yes and '2' for no: ");
  1495.                                                     scanf("%d", &choice);                                
  1496.                                                    
  1497.                                                     printf("\n\n\n\n\n\n\n\n\n");
  1498.  
  1499.                                                     if (choice == 2)
  1500.                                                      {
  1501.                                                         printf("resetting..\n\n\n\n\n");
  1502.                                                         sleep(2);                                                      
  1503.                                                         break;
  1504.                                                      }
  1505.                                                  }
  1506.                                                }
  1507.                                              
  1508.                                              
  1509.    
  1510.                                                
  1511.                                                
  1512.                                          if (choice == 2)
  1513.                                           {
  1514.                                             choice = 0;
  1515.                                             break;
  1516.                                           }    
  1517.    
  1518.                                            
  1519.                                         }
  1520.  
  1521.                                       }
  1522.                                      
  1523.                                      
  1524.                                      
  1525.                                      
  1526.                                      
  1527.                                       if (choice == 2)
  1528.                                            {
  1529.                                             inventoryprint();
  1530.                                                 choice = 0;
  1531.                                                 while (choice != 2)
  1532.                                                  {
  1533.                                                 printf("ENTER THE ID# OF THE ITEM TO REMOVE: ");
  1534.                                                 scanf("%d", &b);
  1535.                                                
  1536.                                                 for(a=0;a<x;a++)
  1537.                                                  {
  1538.                                                     if(a == b)
  1539.                                                      {
  1540.                                                         admit = 1;
  1541.                                                         break; 
  1542.                                                      }
  1543.                                                     else
  1544.                                                         admit = 0;
  1545.                                                  }
  1546.                                                  
  1547.                                                 if (admit == 1)
  1548.                                                  {
  1549.    
  1550.                                                     inventory.stock[a]=0;
  1551.                                                     inventory.bp[a]=0;
  1552.                                                     inventory.sp[a]=0;
  1553.                                                     inventory.sold[a]=0;
  1554.                                                     inventory.spoiltquantity[a]=0;
  1555.                                                     strcpy(inventory.itemname[a],"\0");
  1556.                                                     inventory.spoiltloss[a]=0;
  1557.                                                     inventory.profit_loss[a]=0;
  1558.                                                    
  1559.                                                     for (b=a;b<y;b++)
  1560.                                                      {
  1561.                                                         strcpy(inventory.itemname[b],"\n");
  1562.                                                         inventory.bp[b] = inventory.bp[b+1];
  1563.                                                         inventory.sp[b] = inventory.sp[b+1];
  1564.                                                         inventory.sold[b] = inventory.sold[b+1];
  1565.                                                         inventory.spoiltquantity[b] = inventory.spoiltquantity[b+1];
  1566.                                                         inventory.spoiltloss[b] = inventory.spoiltloss[b+1];
  1567.                                                         inventory.profit_loss[b] = inventory.profit_loss[b+1];
  1568.                                                      }
  1569.                                                     itemCNT--;
  1570.                                                     printf("\n\n\n\n\n");
  1571.                                                     printf("ITEM SUCCESSFULLY REMOVED.\n");
  1572.                                                     sleep(3);
  1573.                                        
  1574.                                                     for (y=0;y<3000;y++)
  1575.                                                      {
  1576.                                                         printf("\n\n\n\n\n\n\n\n\n");
  1577.                                                      } 
  1578.                                                      
  1579.                                                    
  1580.                                                  }
  1581.                                                  else
  1582.                                                   {
  1583.                                                     printf("\n\n\n\n");
  1584.                                                     printf("ITEM NOT FOUND..");
  1585.                                                     sleep(3);
  1586.                                                   }
  1587.                                                  
  1588.                                                  
  1589.                                                     printf("\n\n\n\n\n");
  1590.                                                     printf("Continue? Enter '1' for yes and '2' for no: ");
  1591.                                                     scanf("%d", &choice);                                
  1592.                                                    
  1593.                                                     printf("\n\n\n\n\n\n\n\n\n");
  1594.  
  1595.                                                     if (choice == 2)
  1596.                                                      {
  1597.                                                         choice = 0;
  1598.                                                         printf("resetting..\n");
  1599.                                                         sleep(2);                                                      
  1600.                                                         break;
  1601.                                                      }
  1602.                                                    }  
  1603.  
  1604.                                            }
  1605.  
  1606.                                  }
  1607.                                 else
  1608.                                  {
  1609.                                     printf("\n\n\n\n\n");
  1610.                                     printf("INCORRECT ADMINISTRATOR PASSWORD");
  1611.                                     sleep(3);
  1612.                                     printf("\nresetting..");
  1613.                                     sleep(2);
  1614.                                     for (y=0;y<3000;y++)
  1615.                                      {
  1616.                                       printf("\n\n\n\n\n\n\n\n\n");
  1617.                                      }
  1618.                      
  1619.                                     break;
  1620.                                  }
  1621.                               }
  1622.                             }
  1623.                           }                
  1624.                          
  1625.                              
  1626.  
  1627.  
  1628.  
  1629.  
  1630.                          if (choice == 4)
  1631.                           {
  1632.                            choice=0;
  1633.                            printf("Contact Administrator to gain access.\n");
  1634.                            printf("PASSWORD: ");
  1635.                            scanf("%s", testpassword);
  1636.                            if (strcmp(testpassword,password) == 0)
  1637.                             {
  1638.                                 edititem();
  1639.                             }
  1640.                            else
  1641.                             {
  1642.                                 printf("\n\n\nINCORRECT PASSWORD");
  1643.                                 sleep(2);
  1644.                                 printf("resetting..");
  1645.                                 sleep(2);
  1646.                             }
  1647.                            
  1648.                           }
  1649.                        
  1650.                          /*Item Search*/     
  1651.                          if (choice == 5)
  1652.                           {
  1653.                            choice=0;
  1654.                            printf("\n\n\n");
  1655.                            printf("Enter item name: ");
  1656.                            scanf("%s", container);
  1657.                            
  1658.                            for (a=0;a<itemCNT;a++)
  1659.                             {
  1660.                                 if (strcmp(container,inventory.itemname[a]) == 0)
  1661.                                  {
  1662.                                     admit = 1;
  1663.                                     break;
  1664.                                  }
  1665.                                 else
  1666.                                  {
  1667.                                     admit = 0;
  1668.                                  }
  1669.                                  
  1670.                             }
  1671.                            
  1672.                            if (admit == 1)
  1673.                             {
  1674.                                 printf("\n\n");
  1675.                                 printf("ITEM FOUND\n\n");
  1676.                                
  1677.                               printf("\n\n\n\n\n");
  1678.                               printf("***********************************************************************************************************************************************************************\n");
  1679.                               printf("|  ID#   |            ITEM            |  STOCK  |  BUYING PRICE  |  SELLING PRICE  |     SOLD     |   SPOILT QNTY   |   SPOILT LOSS   |          PROFIT/LOSS          |\n");      
  1680.                               printf("***********************************************************************************************************************************************************************\n\n");
  1681.                               printf("%4d", a);
  1682.                               printf("%26s", inventory.itemname[a]);
  1683.                               printf("%15.1f", inventory.stock[a]);
  1684.                               printf("%15.2f", inventory.bp[a]);
  1685.                               printf("%17.2f", inventory.sp[a]);
  1686.                               printf("%16.1f", inventory.sold[a]);
  1687.                               printf("%17.1f", inventory.spoiltquantity[a]);
  1688.                               printf("%19.2f", inventory.spoiltloss[a]);
  1689.                               printf("%29.2f", inventory.profit_loss[a]);
  1690.                        
  1691.                                sleep(3);
  1692.                                printf("\n\n\n\n\n\n\n\n\n\n\nEnter anything to exit..");
  1693.                                char input[1];
  1694.                                scanf("%s",input);
  1695.                             }
  1696.                            else
  1697.                             {
  1698.                                 printf("ITEM NOT FOUND..\n\n");
  1699.                             }
  1700.                           }
  1701.                        
  1702.                          /*Start POS*/   
  1703.                          if (choice == 6)
  1704.                           {
  1705.                           choice=0;
  1706.                           while(choice != 2)
  1707.                            {
  1708.                             printf("\n\n\n\n");
  1709.                             printf("*************\n");
  1710.                             printf("POINT OF SALE\n");
  1711.                             printf("*************\n\n\n");
  1712.                
  1713.                             printf("  ****\n");
  1714.                             printf("  MENU\n");
  1715.                             printf("  ****\n\n");
  1716.                
  1717.                             printf("    1] Start New Transaction\n");
  1718.                             printf("    2] Exit\n\n");
  1719.                
  1720.                             printf("Choice: ");
  1721.                             scanf("%d", &choice);
  1722.                             for (y=0;y<3000;y++)
  1723.                              {
  1724.                               printf("\n\n\n\n\n\n\n\n\n");
  1725.                              }
  1726.                             sleep(2);
  1727.                
  1728.                
  1729.                
  1730.                
  1731.                
  1732.                             /*NEW TRANSACTION*/
  1733.                             if(choice == 1)
  1734.                              {
  1735.                               posCNT=0;
  1736.                               pos.subtotal = 0;
  1737.                               pos.total = 0;
  1738.                               pos.transaction++;
  1739.                               printf("\n\n");
  1740.  
  1741.    
  1742.    
  1743.    
  1744.    
  1745.    
  1746.    
  1747.                
  1748.                               for(x=0;x<1000;x++)
  1749.                                {
  1750.                                 choice = 0;
  1751.  
  1752.                                
  1753.                                
  1754.                                 if (x==0)
  1755.                                  {
  1756.                                   printf("*******************************************************************************\n");
  1757.                                   printf("|  ITEM#   |     ITEM       |    UNIT PRICE    |    QUANTITY      |    COST   |\n");
  1758.                                   printf("*******************************************************************************\n\n");
  1759.                                   printf("\n\n\n\n\n\n");
  1760.                                   printf("\n\n                                      TAX = ");
  1761.                                   printf("%.4f", pos.tax);
  1762.                                   printf("\n");
  1763.                                   printf("                                      SUBTOTAL = ");
  1764.                                   printf("%.2f", pos.subtotal);
  1765.                                   printf("\n");
  1766.                                   printf("                                      TOTAL = ");
  1767.                                   printf("%.2f", pos.total);
  1768.                                   printf("\n\n\n\n\n\n\n\n");
  1769.                                 }
  1770.  
  1771.                
  1772.                
  1773.                
  1774.                                  printf("\n\n\n\nSelect Choice: \n\n");
  1775.                                  printf("1]Add Item\n");
  1776.                                  printf("2]Remove item\n");
  1777.                                  printf("3]End transaction\n\n");
  1778.                                  printf("Choice: ");
  1779.                                  scanf("%d", &choice);
  1780.                                
  1781.                                
  1782.                                
  1783.                                
  1784.                                 if (choice == 1)
  1785.                                  {
  1786.                                     printf(" Enter item name: ");
  1787.                                     scanf("%s", container);
  1788.                                    
  1789.                                    
  1790.                                     for (a=0;a<y;a++)
  1791.                                      {
  1792.                                         if (strcmp(container,pos.itemname[a]) == 0)
  1793.                                          {
  1794.                                             admit = 1;
  1795.                                             break;
  1796.                                          }
  1797.                                         else
  1798.                                          admit = 0;
  1799.                                      }
  1800.                                      
  1801.  
  1802.                                      if (admit == 1)
  1803.                                       {
  1804.                                         printf("\n\n");
  1805.                                         printf("NO DUPLICATE ITEM NAMES PLEASE.\n");
  1806.                                         x=x-1;
  1807.                                         sleep(2);
  1808.                                       }
  1809.                                     else/*ITEM DOES NOT DUPLICATE*/
  1810.                                     {
  1811.                                         strcpy(pos.itemname[x],container);
  1812.                                         for(z=0;z<10000;z++)
  1813.                                          {
  1814.                                             if(strcmp(pos.itemname[x],inventory.itemname[z]) == 0)
  1815.                                              {
  1816.                                               pos.sp[x] = inventory.sp[z];
  1817.                                               pos.pricenotax = (pos.sp[x] * pos.quantity[x]);
  1818.                                               pos.price[x] = pos.sp[x]*pos.quantity[x];
  1819.                                               pos.subtotal = pos.subtotal + pos.price[x];
  1820.                                               break;
  1821.                                              }
  1822.                                             if(z==9999)
  1823.                                              {
  1824.                                               printf (" Item not found in the inventory, manually set its unit price: ");
  1825.                                               scanf ("%f", &pos.sp[x]);
  1826.                                               pos.price[x] = pos.sp[x]*pos.quantity[x];
  1827.                                               pos.subtotal = pos.subtotal + pos.price[x];
  1828.                                               printf ("\n\n");
  1829.                                              }
  1830.                                          }
  1831.                                        
  1832.  
  1833.                                         printf(" Enter item quantity: ");
  1834.                                         scanf("%f", &floatcontainer);
  1835.                                        
  1836.                                             /*QUANTITY IS GREATER THAN STOCK AVALIABLE*/
  1837.                                             if ((strcmp(pos.itemname[x],inventory.itemname[z]) == 0) && floatcontainer > inventory.stock[a])
  1838.                                              {
  1839.                                                 admit = 1;
  1840.                                              }
  1841.                                             else
  1842.                                              admit = 0;
  1843.  
  1844.                                         if (admit == 1)
  1845.                                          {
  1846.                                            
  1847.                                            
  1848.                                             while (floatcontainer > inventory.stock[z])
  1849.                                              {
  1850.                                                 printf("\n\nERROR: QUANTITY IS GREATER THAN STOCK AVALIABLE\n");
  1851.                                                 printf("Re-Enter Quantity: ");
  1852.                                                 scanf("%f", &floatcontainer);
  1853.                                                 if (floatcontainer < inventory.stock[z])
  1854.                                                  {
  1855.                                                     admit=0;
  1856.                                                     break;
  1857.                                                  }
  1858.                                              } 
  1859.                                          }
  1860.                                         else
  1861.                                          {
  1862.                                            pos.quantity[x] = floatcontainer;
  1863.                                          }
  1864.                                          
  1865.                                          
  1866.  
  1867.                                          posCNT++;
  1868.                                     }
  1869.                                 }
  1870.                                
  1871.                                
  1872.  
  1873.                
  1874.                
  1875.                
  1876.                
  1877.                                  if(choice==2)
  1878.                                   {
  1879.                                    printf("Enter the item number of the item which is to be removed: ");
  1880.                                    scanf("%d", &idno);
  1881.                                    printf("\n\n\n");
  1882.                                    
  1883.                                    for (a=0;a<x;a++)
  1884.                                     {
  1885.                                         if (a==idno)
  1886.                                          {
  1887.                                             admit = 1;
  1888.                                             break;
  1889.                                          } 
  1890.                                         else
  1891.                                          admit = 0;
  1892.                                     }
  1893.                                    
  1894.                                    if (admit == 1)
  1895.                                     {
  1896.                                         strcpy(pos.itemname[a],"\0");
  1897.                                         pos.sp[a] = 0;
  1898.                                         pos.quantity[a] = 0;
  1899.                                        
  1900.                                         for (b=a;b<x;b++)
  1901.                                          {
  1902.                                             strcpy(pos.itemname[b],pos.itemname[b+1]);
  1903.                                             pos.sp[b] = pos.sp[b+1];
  1904.                                             pos.quantity[b] = pos.quantity[b+1];
  1905.                                             pos.price[b] = pos.price[b+1];
  1906.                                          }
  1907.                                         pos.subtotal = pos.subtotal - pos.price[a];
  1908.                                         posCNT--;
  1909.                                        printf("ITEM SUCCESSFULLY REMOVED.\n");
  1910.                                        sleep(3);
  1911.                                        x--;
  1912.                                        printf("resetting..");
  1913.                                        sleep(2);
  1914.                                     }
  1915.                                    else
  1916.                                     {
  1917.                                         printf("ITEM NUMBER NOT FOUND..");
  1918.                                         sleep(2);
  1919.                                         printf("\nresetting..");
  1920.                                         sleep(1);
  1921.                                         x--;
  1922.                                         for (y=0;y<3000;y++)
  1923.                                          {
  1924.                                             printf("\n\n\n\n\n\n\n\n\n");
  1925.                                          } 
  1926.                                     }
  1927.                                   }
  1928.                                    
  1929.                                    
  1930.                                    
  1931.                                    
  1932.                                    
  1933.                                     pos.price[y] = pos.sp[y]*pos.quantity[y];
  1934.                                    
  1935.                                     pos.quantity[x] = floatcontainer;  
  1936.                                     printf("\n\n\nTRANSACTION NUMBER: ");
  1937.                                     printf("%d", pos.transaction);
  1938.                                     printf("\n\n");
  1939.                                    
  1940.                                     printf("*******************************************************************************\n");
  1941.                                     printf("|  ITEM#   |     ITEM       |    UNIT PRICE    |    QUANTITY      |    COST   |\n");
  1942.                                     printf("*******************************************************************************\n\n");
  1943.                                     for(y=0;y<=x;y++)
  1944.                                      {
  1945.                                       printf("%6d", y);
  1946.                                       printf ("%20s", pos.itemname[y]);
  1947.                                       printf ("%15.2f",   pos.sp[y]);
  1948.                                       printf ("%18.1f", pos.quantity[y]);
  1949.                                       printf ("%17.2f", pos.price[y] = pos.sp[y]*pos.quantity[y]);
  1950.                                      
  1951.                                       printf ("\n\n");
  1952.                                      }
  1953.                                      
  1954.                                    pos.subtotal = 0;
  1955.                                    for (a=0;a<posCNT;a++)
  1956.                                     {
  1957.                                           pos.subtotal = pos.subtotal + pos.price[a];
  1958.                                     }
  1959.                                    
  1960.                                    
  1961.                                    printf("\n\n\n\n\n");
  1962.                                    printf("\n\nTAX = ");
  1963.                                    printf("%.4f", pos.tax);
  1964.                                    printf("\n");
  1965.                                    printf("SUBTOTAL = $");
  1966.                                    printf("%.2f", pos.subtotal);
  1967.                                    printf("\n");
  1968.                                    
  1969.                                    printf("TOTAL = $");
  1970.                                    pos.total = pos.subtotal + (pos.subtotal*pos.tax);
  1971.                                    printf("%.2f", pos.total);
  1972.                
  1973.                
  1974.                
  1975.                                  if(choice==3)
  1976.                                   {
  1977.                                    
  1978.                                    pos.total = pos.subtotal + (pos.subtotal*pos.tax);
  1979.                                    printf("\n\n\n\n\n");
  1980.                                    printf("\n\nTAX = ");
  1981.                                    printf("%.4f", pos.tax);
  1982.                                    printf("\n");
  1983.                                    printf("SUBTOTAL = $");
  1984.                                    printf("%.2f", pos.subtotal);
  1985.                                    printf("\n");
  1986.                                    
  1987.                                    printf("TOTAL = $");
  1988.                                    printf("%.2f", pos.total);
  1989.                                    printf("\n\n\n\n");
  1990.                                    printf("\n\n\nEnter Cash Tendered: $");
  1991.                                    scanf("%f", &pos.cashtendered);
  1992.                                    printf("\n\n\n");
  1993.                                                        
  1994.                                  if (pos.cashtendered<pos.total)
  1995.                                   {
  1996.                                    printf("Cash tendered is insufficient to complete the transaction. It will not be accounted for. Enter '1' to re-enter and '2' to quit: ");
  1997.                                    scanf("%d", &choice);
  1998.            
  1999.                                    if(choice==2)
  2000.                                    {
  2001.                                     choice=0;
  2002.                                     break;
  2003.                                    }
  2004.                                   }
  2005.                                    
  2006.                                    
  2007.                                    
  2008.                                    
  2009.                                    while (pos.cashtendered<pos.total)
  2010.                                     {        
  2011.                                        choice=0;
  2012.                                        printf("\n\n\n\n\n");
  2013.                                        printf("\n\nTAX = ");
  2014.                                        printf("%.4f", pos.tax);
  2015.                                        printf("\n");
  2016.                                        printf("SUBTOTAL = $");
  2017.                                        printf("%.2f", pos.subtotal);
  2018.                                        printf("\n");
  2019.                                        printf("TOTAL = $");
  2020.                                        printf("%.2f", pos.total);
  2021.                                        printf("\n\n\n\n");
  2022.                                        choice=0;
  2023.                                        
  2024.                                          printf("\n\n\nRenter Cash Tendered: $");
  2025.                                          scanf("%f", &pos.cashtendered);
  2026.                    
  2027.                    
  2028.                    
  2029.                    
  2030.                    
  2031.                                        if (pos.cashtendered<pos.total)
  2032.                                           {
  2033.                                            printf("Cash tendered is insufficient to complete the transaction. It will not be accounted for. Enter '1' to re-enter and '2' to quit: ");
  2034.                                            scanf("%d", &choice);
  2035.                    
  2036.                                            if(choice==2)
  2037.                                            {
  2038.                                             choice=0;
  2039.                                             break;
  2040.                                            }
  2041.                                           }
  2042.  
  2043.                                     }
  2044.                                    
  2045.                                    
  2046.                                    
  2047.                                     if(pos.cashtendered >= pos.total)
  2048.                                           {
  2049.                                            pos.change = pos.cashtendered - pos.total;
  2050.                    
  2051.                                            printf("\n\n\n\n");
  2052.                                            printf("\n\nTAX = ");
  2053.                                            printf("%.4f", pos.tax);
  2054.                                            printf("\n");
  2055.                                            printf("SUBTOTAL = $");
  2056.                                            printf("%.2f", pos.subtotal);
  2057.                                            printf("\n");
  2058.                                            printf("TOTAL = $");
  2059.                                            printf("%.2f", pos.total);
  2060.                                            printf("\n\n");
  2061.                                            printf("Cash Tendered: $");
  2062.                                            printf("%.2f", pos.cashtendered);
  2063.                                            printf("\n");
  2064.                                            printf("Change due: $");
  2065.                                            printf("%.2f", pos.change);
  2066.                    
  2067.                                          
  2068.                                            for (b=0;b<10000;b++)
  2069.                                             {
  2070.                                                 for (a=0;a<1000;a++)       
  2071.                                                  {
  2072.                                                   if (strcmp(pos.itemname[a],inventory.itemname[b]) == 0)
  2073.                                                    {
  2074.                                                         inventory.stock[b] = inventory.stock[b] - pos.quantity[a];
  2075.                                                         inventory.sold[b] = inventory.sold[b] + pos.quantity[a];
  2076.                                                    }
  2077.                                                  }
  2078.                                             }  
  2079.  
  2080.                                                
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.                                            printf("\n\n\n                                       Have a nice day!!!");
  2087.                                            for(a=0;a<x;a++)
  2088.                                             {
  2089.                                                 strcpy(pos.itemname[a],"");
  2090.                                             }
  2091.                                            sleep(3);
  2092.                                            printf("\n\n\n\n\n\n\n\n\n\n\nEnter anything to exit..");
  2093.                                            char input[1];
  2094.                                            scanf("%s",input);
  2095.                                            if (strcmp(input,"") != 0)
  2096.                                            break;
  2097.                                           }
  2098.                    
  2099.                                  }
  2100.                
  2101.  
  2102.  
  2103.  
  2104.  
  2105.                
  2106.                                   }
  2107.                                }
  2108.                
  2109.                
  2110.                              }
  2111.                
  2112.                           }
  2113.                          
  2114.                           if (choice == 7)
  2115.                            {
  2116.                             printf("\n\n\n");
  2117.                             printf("LOGGING OFF...");
  2118.                             sleep(3);
  2119.                             break;
  2120.                            }
  2121.                           printf("\n\n\n\n\n\n");
  2122.                       }
  2123.                      }
  2124.                     else
  2125.                      {
  2126.                       printf("\n\n\n");
  2127.                       printf("INCORRECT PASSWORD.\nresetting..");
  2128.                       sleep(3);
  2129.                       for (y=0;y<3000;y++)
  2130.                        {
  2131.                         printf("\n\n\n\n\n\n\n\n\n");
  2132.                        }
  2133.                      }
  2134.                  }
  2135.  
  2136.                  
  2137.              }
  2138.           }
  2139.          
  2140.          
  2141.          
  2142.          
  2143.           return 0;
  2144.       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement