Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
int choice, donationchoice, protein, totalprotein, dairy, totaldairy, totalrequestfruits;
int grains, totalgrains, vegetables, totalvegetables, fruits, totalfruits;
int requestchoice, requestprotein, totalrequestprotein, requestdairy, totalrequestdairy;
int requestgrains, totalrequestgrains, requestvegetables, totalrequestvegetables, requestfruits;
printf("Welcome to the Food Bank Management Program!\n");
while (choice !=5){
printf("\nWhat would you like to do?\n");
printf("\t1. - Enter a Donation\n");
printf("\t2. - Enter a request\n");
printf("\t3. - Fulfill Requests\n");
printf("\t4. - Print status report\n");
printf("\t5. - Exit\n");
scanf("%d", &choice);
switch(choice){
case 1:
printf("What donation type would you like to enter?\n");
printf("\t0. Protein\n");
printf("\t1. Dairy\n");
printf("\t2. Grains\n");
printf("\t3. Vegetables\n");
printf("\t4. Fruits\n");
scanf("%d", &donationchoice);
switch (donationchoice !=5){
case 0:
printf("How many would you like to enter?");
scanf("%d", &protein);
totalprotein = totalprotein + protein;
printf("Donation Added.\n");
break;
case 1:
printf("How many would you like to enter?");
scanf("%d", &dairy);
totaldairy = totaldairy + dairy;
printf("Donation Added.\n");
break;
case 2:
printf("How many would you like to enter?");
scanf("%d", grains);
totalgrains = totalgrains + grains;
printf("Donation Added.\n");
break;
case 3:
printf("How many would you like to enter?");
scanf("%d", &vegetables);
totalvegetables = totalvegetables + vegetables;
printf("Donation Added.\n");
break;
case 4:
printf("How many would you like to enter?");
scanf("%d", &fruits);
totalfruits = totalfruits + fruits;
printf("Donation Added.\n");
break;
break;
}//end of donation choice switch statement/ case 1 of original choice switch
case 2:
switch(requestchoice){
case 0:
printf("How many would you like to request?");
scanf("%d", requestprotein);
totalrequestprotein += requestprotein;
printf("Request Added.\n");
break;
case 1:
printf("How many would you like to request?");
scanf("%d", requestdairy);
totalrequestdairy += requestdairy;
printf("Request Added.\n");
break;
case 2:
printf("How many would you like to request?");
scanf("%d", requestgrains);
totalrequestgrains += requestgrains;
printf("Request Added.\n");
break;
case 3:
printf("How many would you like to request?");
scanf("%d", requestvegetables);
totalrequestvegetables += requestvegetables;
printf("Request Added.\n");
break;
case 4:
printf("How many would you like to request?\n");
scanf("%d", requestfruits);
totalrequestfruits += requestfruits;
printf("Request Added.\n");
break;
break;
}//end request switch
case 3:
/*
if (totalprotein>totalrequestprotein){
printf("Requests will be fufilled.\n");
totalprotein = totalprotein - totalrequestprotein;
totalrequestprotein = 0;
}
if (totaldairy>totalrequestdairy){
printf("Requests will be fufilled.\n");
totaldairy = totaldairy - totalrequestdairy;
totalrequestdairy = 0;
}
if (totalgrains>totalrequestgrains){
printf("Requests will be fufilled.\n");
totalgrains = totalgrains - totalrequestgrains;
totalrequestgrains = 0;
}
if (totalvegetables>totalrequestvegetables){
printf("Requests will be fufilled.\n");
totalvegetables = totalvegetables - totalrequestvegetables;
totalrequestvegetables = 0;
}
if (totalfruits>totalrequestfruits){
printf("Requests will be fufilled.\n");
totalfruits = totalfruits - totalrequestfruits;
totalrequestfruits = 0;
}
*/
break;
case 4:
printf("Protein: Donations:%d Requests:%d\n", totalprotein, totalrequestprotein);
printf("Dairy: Donations:%d Requests:%d\n", totaldairy, totalrequestdairy);
printf("Grains: Donations:%d Requests:%d\n", totalgrains, totalrequestgrains);
printf("Vegetables: Donations:%d Requests:%d\n", totalvegetables, totalrequestvegetables);
printf("Fruits: Donations:%d Requests:%d\n", totalfruits, totalrequestfruits);
break;
case 5:
printf("Thank you for running our system!");
exit(0);
break;
default:
printf("You've made an invalid selection.\n");
}//end switch
}//end while
return 0;
}