so know this is what i get
There are 4 items in inventory.
There are 3 items in the grocery list.
Purchasing:
Item: potatoes insufficient quantity
Item: 2-liter soda insufficient quantity
pounds of hamburger 2 $4.98
-------------------------
Total Cost: $ 4.98
with this code:
Code:int availability(Grocery_Arr groc_list, InvArr inv_list, int num_grocItems, int num_invItems){ int compare, groc_count, inv_count; float total = 0.0, new_price; for(groc_count = 0; groc_count < num_grocItems; groc_count++){ for(inv_count = 0; inv_count < num_invItems; inv_count++){ compare = strcmp(groc_list[groc_count].name, inv_list[inv_count].name); /*COMPARE THE NAMES OF THE ITEMS*/ if(compare == 0) break; } if(groc_list[groc_count].quantity <= inv_list[inv_count].quantity){ /*IF AVAILABLE FOR PURCHASE*/ new_price = ((float)groc_list[groc_count].quantity * inv_list[inv_count].price); /*CALCULATE NEW PRICE*/ printf("%s %d $%.2f\n", groc_list[groc_count].name, groc_list[groc_count].quantity, new_price); total += new_price; /*CALCULATE NEW TOTAL*/ } else if(groc_list[groc_count].quantity > inv_list[inv_count].quantity) /*IF AVAILABLE BUT NOT RIGHT QUANTITY*/ printf("Item: %s insufficient quantity\n",groc_list[groc_count].name); else printf("Item: %s does not exist\n",groc_list[groc_count].name); /*IF ITEM DOES NOT EXIST*/ } printf("-------------------------\n"); printf("Total Cost: $ %.2f\n",total); return total; }

