FANDOM


/* MADE BY Kevin Duke and Tomi Babalola */
/* Program 4 */
/* 12/4/09 */
 
#include <stdio.h>
#include <string.h>
#define STRSIZ 20
 
struct inventory{
      char product_cat,    /* Catergory of each product */
	dept_name[STRSIZ],
	  product_name[STRSIZ],   /* Name of the product */
      meat_type,              /* type of meat */
	  plants,	  /* fruit or veggie */
	  aisle_side,  /* side of asile */
	  nonfood_cat; /*category of nonfood item*/
      int cost_item;    /* Cost of item in cents */
      int packaging_date,  /* Date of packaging */
	  expiration_date, /* Date of expiration */
	  aisle_number;
};
 
void vprint_data(struct inventory any_product)
{
   printf("\n\n");
   printf("We have %s in our %s Dept. It costs %d cents per pound. It was packed on %d and will expire on %d.\n", any_product.product_name, any_product.dept_name, any_product.cost_item, any_product.packaging_date, any_product.expiration_date);
}
 
int main (void)
{
  struct inventory any_product;
  char pad; /*absorbs stray \n from buffer */
 
  printf("Enter product category (M,P,D,C,N,Q): ");
  scanf("%c", &any_product.product_cat);
  printf("%c\n", any_product.product_cat);
  scanf("%c", &pad); /*absorbs stray \n from buffer */
 
  switch (any_product.product_cat)
     {
     case 'm':
     case 'M':
          printf("Meats\n");
          strcpy(any_product.dept_name, "Meat");
 
 
		  printf("Enter meat type (R, P, F): ");
          scanf("%c", &any_product.meat_type);
          printf("%c\n", any_product.meat_type);
 
		   switch (any_product.meat_type)
		    {
			case 'R':
			case 'r':
			    printf("Red meat\n");
                break;
			case 'P':
			case 'p':
			    printf("Poultry\n");
				break;
			case 'F':
			case 'f':
			    printf("Fish\n");
				break;
			default:
			    printf("Invalid meat type\n");
			}
 
		break;
 
     case 'p':
     case 'P':
       printf("Produce\n");
       strcpy(any_product.dept_name, "Produce");
 
	   printf("Enter 'F' for fruit and 'V' for veggitable: ");
	   scanf("%c", &any_product.plants);
	   printf("%c\n", any_product.plants);
 
	   break;
 
     case 'D':
     case 'd':
       printf("Dairy\n");
       strcpy(any_product.dept_name, "Dairy");
 
       break;
 
	  case 'C':
      case 'c':
       printf("Canned goods\n");
       strcpy(any_product.dept_name, "Canned goods");
 
	   printf("Enter aisle number: ");
	   scanf("%d", &any_product.aisle_number);
	   printf("%d\n", any_product.aisle_number);
           scanf("%c", &pad); /*absorbs stray \n from buffer */
 
	   printf("Enter aisle side ('A' or 'B'): ");
	   scanf("%c", &any_product.aisle_side);
	   printf("%c\n", any_product.aisle_side);
	  	   break;
 
     case 'N':
     case 'n':
       printf("Nonfoods\n");
       strcpy(any_product.dept_name, "Nonfoods");
 
 
	   printf("Enter category of nonfood item ('C' for cleaning product, 'P' for pharmacy, 'O' for other): ");
       scanf("%c", &any_product.nonfood_cat);
       scanf("%c", &pad); /*absorbs stray \n from buffer */
	    if(any_product.nonfood_cat != 'C' && any_product.nonfood_cat != 'P' && any_product.nonfood_cat != 'O')
	      printf("Invalid nonfood category letter\n");
	   else printf("%c\n", any_product.nonfood_cat);
 
	   printf("Enter aisle number: ");
	   scanf("%d", &any_product.aisle_number);
	   scanf("%c", &pad); /*absorbs stray \n from buffer */
	   printf("%d\n", any_product.aisle_number);
 
	   printf("Enter aisle side ('A' or 'B'): ");
	   scanf("%c", &any_product.aisle_side);
	   printf("%c\n", any_product.aisle_side);
	   break;
 
	 case 'Q':
	 case 'q':
	   printf("Quited\n");
	   return 0;
 
	 default:
       printf("Invalid product category\n");
	   return 0;
     }
 
 printf("Enter recieved date (MMDDYY): ");
	   scanf("%d", &any_product.packaging_date);
	   printf("%d\n", any_product.packaging_date);
 
 printf("Enter date of expiration (MMDDYY): ");
	   scanf("%d", &any_product.expiration_date);
	   printf("%d\n", any_product.expiration_date);
 
 printf("Enter product name: ");
          scanf("%s", any_product.product_name);
          printf("%s\n", any_product.product_name);
 
 printf("Enter cost of item in cents: ");
          scanf("%d", &any_product.cost_item);
          printf("%d\n", any_product.cost_item);
 
vprint_data(any_product);
 
return 0;
  }