Hello all i am new to the programming world and i have come accross a problem. i am trying to use a menu and repeat it after i have collected input from the user.
Here is the code right now. When running it, the outcomes of the first step is correct. But when t choose from the first menu it givs me only what i made choice 1 to be for all choices. and then stops.
i would like it to take in input from the user and repeat the main menu again.
any help is apriciated
Code:
int main() {
int choice=1, type_don=0, type_req=0, choice_don=1, choice_req;
printf("Welcome to the Food Bank Management Program!\n\n");
printf("What would you like to do?\n");
printf("\t 1. Enter a Donation\n");
printf("\t 2. Enter a Request\n");
printf("\t 3. Fullfill Request\n");
printf("\t 4. Print status report\n");
printf("\t 5. Exit\n");
scanf("&d", &choice);
while (choice != 2) {{
if (choice == 1) {
printf("What donation type would you like to make\n");
printf("0. Protein\n");
printf("1. Dairy\n");
printf("2. Grains\n");
printf("3. Vegetables\n");
printf("4. Fruits\n");
scanf("%d", &type_don);
for (choice_don != 2) {
int don_list[5], don_pro, don_dai, don_gra, don_veg, don_fru;
if (choice_don == 1) {
printf("How many would you like to enter?\n");
scanf("%d", don_pro);
don_pro = don_list[1];
}
else if (choice_don == 2) {
printf("How many would you like to enter?\n");
scanf("&d", don_dai);
don_dai = don_list[2];
}
else if (choice_don == 3) {
printf("How many would you like to enter?\n");
scanf("%d", don_gra);
don_gra = don_list[3];
}
else if (choice_don == 4) {
printf("How many would you like to enter?\n");
scanf("%d", don_veg);
don_veg = don_list[4];
}
else if (choice_don == 5)
printf("How many would you like to enter?\n");
scanf("%d", don_fru);
don_fru = don_list[5];
}}
else if (choice == 2) {
printf("What would you like to request?\n");
printf("0. Protein\n");
printf("1. Dairy\n");
printf("2. Grains\n");
printf("3. Vegetables\n");
printf("4. Fruits\n");
scanf("%d", &type_req);
while (choice_req !=5) {
int req_list[5], req_pro, req_dai, req_gra, req_veg, req_fru;
if (choice == 1) {
printf("How many would you like to enter?\n");
scanf("%d", req_pro);
req_pro = req_list[1];
}
else if (choice == 2) {
printf("How many would you like to enter?\n");
scanf("&d", req_dai);
req_dai = req_list[2];
}
else if (choice == 3) {
printf("How many would you like to enter?\n");
scanf("%d", req_gra);
req_gra = req_list[3];
}
else if (choice == 4) {
printf("How many would you like to enter?\n");
scanf("%d", req_veg);
req_veg = req_list[4];
}
else if (choice == 5) {
printf("How many would you like to enter?\n");
scanf("%d", req_fru);
req_fru = req_list[5];
}}}
else if (choice == 3) {
printf("no");
}
else if (choice == 4) {
printf("yes");
}
else if (choice == 5) {
printf("Thank you for running our system!");
}
}}
return 0;
}