/* Sandra N. Kardaras 07/28/04 Fruit Store Inventory Program */ #include /*******************************Function Prototypes***********************/ /*Sales to Customer: Function Prototypes*/ float apples_sale(float total, int apples_sold); float bananas_sale(float total, int bananas_sold); float eggplants_sale(float total, int eggplants_sold); float grapes_sale(float total, int grapes_sold); float prunes_sale(float total, int prunes_sold); /*Purchases for Inventory: Function Prototypes*/ float apples_purchased(float total, int app); float bananas_purchased(float total, int ban); float eggplants_purchased(float total, int egg); float grapes_purchased(float total, int gra); float prunes_purchased(float total, int pru); /*Inventory Status: Function Prototypes*/ int apples_inventory(int apples_sold, int app); int bananas_inventory(int bananas_sold, int ban); int eggplants_inventory(int eggplants_sold, int egg); int grapes_inventory(int grapes_sold, int gra); int prunes_inventory(int prunes_sold, int pru); /*Total Sales: Function Prototype*/ float total_sales(int apples_sold, int bananas_sold, int eggplants_sold, int grapes_sold, int prunes_sold); /*Total Purchases: Function Prototype*/ float total_purchases(float apples_purchased, float bananas_purchased, float eggplants_purchased, float grapes_purchased, float prunes_purchased); main(){ /*Variable Declarations*/ int choice=0; /*Apples variables*/ int app=0; int apples=0; int sum_app=0; int apples_sold=0; /*Bananas variables*/ int ban=0; int bananas=0; int sum_ban=0; int bananas_sold=0; /*Eggplants variables*/ int egg=0; int eggplants=0; int sum_egg=0; int eggplants_sold=0; /*Grapes variables*/ int gra=0; int grapes=0; int sum_gra=0; int grapes_sold=0; /*Prunes variables*/ int pru=0; int prunes=0; int sum_pru=0; int prunes_sold=0; /*Totals variables*/ float total=0; float cash_balance=0; int daily_items_sold=0; int daily_items_purchased=0; /*Sentinel value for while loop*/ char repeat='y'; int MainMenu=0; int MainMenuChoice=0; int SubMenu=0; int SubMenuChoice=0; /*Begins while loop with sentinel value*/ do{ /*Displays menu to user*/ printf("\n\t\t\tFRUIT STORE INVENTORY\n\n"); printf("*******************************MENU*************************************\n\n\n"); printf("\t\t\t\t(Inventory Purchase)\t(Customer Sale)\n"); printf("Item No.\tDescription\tBuying Price\t\tSelling Price\n\n"); printf("#1\t\tApples\t\t$1.00\t\t\t$1.99\n"); printf("#2\t\tBananas\t\t$2.50\t\t\t$3.50\n"); printf("#3\t\tEggplant\t$2.50\t\t\t$3.00\n"); printf("#4\t\tGrapes\t\t$1.00\t\t\t$1.49\n"); printf("#5\t\tPrunes\t\t$0.50\t\t\t$0.75\n\n"); printf("************************************************************************\n\n"); /*Calculates the cash balance*/ cash_balance=100.00f+(total_sales(apples_sold,bananas_sold,eggplants_sold,grapes_sold,prunes_sold)- total_purchases(apples_purchased(total,app), bananas_purchased(total,ban), eggplants_purchased(total,egg), grapes_purchased(total,gra), prunes_purchased(total,pru))); printf("Starting Cash:\t$100.00\n"); printf("Cash Balance:\t$%.2f\n",cash_balance); /*Prints the inventory status*/ printf("\nINVENTORY STATUS:\n\n"); printf("Apples:\t\t%d\n", apples_inventory(apples_sold,app)); printf("Bananas:\t%d\n", bananas_inventory(bananas_sold,ban)); printf("Eggplants:\t%d\n", eggplants_inventory(eggplants_sold,egg)); printf("Grapes:\t\t%d\n", grapes_inventory(grapes_sold,gra)); printf("Prunes:\t\t%d\n", prunes_inventory(prunes_sold,pru)); /*Prompts user to select a Main Menu choice*/ printf("\nHit 1 for a customer sale, 2 for an inventory purchase:\n"); scanf("%d",&MainMenu); /*Error Handling: If statement,verifies if MainMenu selection is valid*/ if(MainMenu<1){ printf("\nThat was not a valid menu option. Please try again.\n"); printf("\nHit 1 for a customer sale, 2 for an inventory purchase:\n"); scanf("%d",&MainMenu); }/*end if*/ /*Error Handling: If statement,verifies if MainMenu selection is valid*/ if(MainMenu>2){ printf("That was not a valid menu option. Please try again.\n"); printf("\nHit 1 for a customer sale, 2 for an inventory purchase:\n"); scanf("%d",&MainMenu); }/*end if*/ /*If statement for MainMenu selection*/ if(MainMenu==1){ /*Prompts user to select a Main Menu item*/ printf("\nCUSTOMER SALE:\n\n"); printf("What was sold?\n"); printf("\nHit 1 for Apples\nHit 2 for Bananas\nHit 3 for Eggplants\nHit 4" " for Grapes\nHit 5 for Prunes\n"); /*Stores input to memory*/ scanf("%d",&MainMenuChoice); /*Error Handling: If statement,verifies if MainMenuChoice selection is valid*/ if(MainMenuChoice<1){ printf("\nThat was not a valid menu option. Please try again.\n"); printf("\nHit 1 for Apples\nHit 2 for Bananas\nHit 3 for Eggplants\nHit 4" " for Grapes\nHit 5 for Prunes\n"); /*Stores input to memory*/ scanf("%d",&MainMenuChoice); }/*end if*/ /*Error Handling: If statement,verifies if MainMenuChoice selection is valid*/ if(MainMenuChoice>5){ printf("\nThat was not a valid menu option. Please try again.\n"); printf("\nHit 1 for Apples\nHit 2 for Bananas\nHit 3 for Eggplants\nHit 4" " for Grapes\nHit 5 for Prunes\n"); /*Stores input to memory*/ scanf("%d",&MainMenuChoice); }/*end if*/ /*Case Statement: Runs upon valid selection of MainMenuChoice*/ switch(MainMenuChoice){ /*Choice is apples*/ case 1: printf("\n\nHow many apples were sold to a customer?\n"); scanf("%d",&apples_sold); /*If statement, verify inventory*/ if (apples_sold>apples_inventory(apples_sold,app)){ printf("Not enough inventory for this sale. See Inventory Status.\n"); } else printf("\nQuantity Sold:\t\t%d\nItem:\t\t\tApples\n" "Cost:\t\t\t$%.2f\n\n",apples_sold, apples_sale(total,apples_sold)); break; /*Choice is bananas*/ case 2: printf("\n\nHow many bananas were sold to a customer?\n"); scanf("%d",&bananas_sold); /*If statement, verify inventory*/ if (bananas_sold>bananas_inventory(bananas_sold,ban)){ printf("Not enough inventory for this sale. See Inventory Status.\n"); } else printf("\nQuantity Sold:\t\t%d\nItem:\t\t\tBananas\n" "Cost:\t\t\t$%.2f\n\n",bananas_sold, bananas_sale(total,bananas_sold)); break; /*Choice is eggplants*/ case 3: printf("\n\nHow many eggplants were sold to a customer?\n"); scanf("%d",&eggplants_sold); /*If statement, verify inventory*/ if (eggplants_sold>eggplants_inventory(eggplants_sold,egg)){ printf("Not enough inventory for this sale. See Inventory Status.\n"); } else printf("\nQuantity Sold:\t\t%d\nItem:\t\t\tEggplants\n" "Cost:\t\t\t$%.2f\n\n",eggplants_sold, eggplants_sale(total,eggplants_sold)); break; /*Choice is grapes*/ case 4: printf("\n\nHow many grapes were sold to a customer?\n"); scanf("%d",&grapes_sold); /*If statement, verify inventory*/ if (grapes_sold>grapes_inventory(grapes_sold,gra)){ printf("Not enough inventory for this sale. See Inventory Status.\n"); } else printf("\nQuantity Sold:\t\t%d\nItem:\t\t\tGrapes\n" "Cost:\t\t\t$%.2f\nn",grapes_sold, grapes_sale(total,grapes_sold)); break; /*Choice is prunes*/ case 5: printf("\n\nHow many prunes were sold to a customer?\n"); scanf("%d",&prunes_sold); /*If statement, verify inventory*/ if (prunes_sold>prunes_inventory(prunes_sold,pru)){ printf("Not enough inventory for this sale. See Inventory Status.\n"); } else printf("\nQuantity Sold:\t\t%d\nItem:\t\t\tPrunes\n" "Cost:\t\t\t$%.2f\n\n",prunes_sold, prunes_sale(total,prunes_sold)); break; }/*end switch*/ }//end if /*If statement, verifies MainMenu selection, goes to SubMenu*/ if(MainMenu==2){ /*Prompts the user to select a SubMenu Item*/ printf("\nINVENTORY PURCHASE:\n\n"); printf("What was purchased?\n"); printf("\nHit 1 for Apples\nHit 2 for Bananas\nHit 3 for eggplants\nHit 4" " for Grapes\nHit 5 for Prunes\n"); /*Stores user input to memory*/ scanf("%d",&SubMenuChoice); /*Error Handling: If statement,verifies if MainMenuChoice selection is valid*/ if(SubMenuChoice<1){ printf("\nThat was not a valid menu option. Please try again.\n"); printf("\nHit 1 for Apples\nHit 2 for Bananas\nHit 3 for Eggplants\nHit 4" " for Grapes\nHit 5 for Prunes\n"); /*Stores input to memory*/ scanf("%d",&SubMenuChoice); }/*end if*/ /*Error Handling: If statement,verifies if MainMenuChoice selection is valid*/ if(SubMenuChoice>5){ printf("\nThat was not a valid menu option. Please try again.\n"); printf("\nHit 1 for Apples\nHit 2 for Bananas\nHit 3 for Eggplants\nHit 4" " for Grapes\nHit 5 for Prunes\n"); /*Stores input to memory*/ scanf("%d",&SubMenuChoice); }/*end if*/ /*Displays menu of choices to user*/ switch(SubMenuChoice){ /*Choice is apples*/ case 1: printf("\n\nHow many apples were purchased for inventory?\n"); scanf("%d",&app); if(cash_balance