SlideShare a Scribd company logo
NEED HELP ON C HOMEWORK
Introduction: Programmers for a Better Tomorrow
Programmers for a Better Tomorrow is an organization dedicated to helping charities, medical
societies, and scholarship organizations manage various tasks so that they can focus on making
the world a better place! They have asked you and your classmates to help them develop some
new programs to benefit their organizations.
Problem: Food Bank Management (foodbank.c)
Programmers for a Better Tomorrow is now in partnership with a local Food Bank which
distributes food items to people in need. People come in to a Food Bank and make their
donations, and others might come in to make a request for any food item they want.
A Food Bank Management Program is used to keep track of the stock the Food Bank has (i.e.,
the donations), keep a record of requests that come in, fulfilling requests and printing the status
report which consists of the amount of stock present in the food bank and the requests that are
not yet fulfilled.
The program will require you to make at least one array. You may choose to make multiple one-
dimensional arrays: one to serve as a Donations Table and one to serve as a Request Table. The
index of the array will represent the inventory type. The value in the array will represent the
amount present or needed of that type.
You may, instead, choose to combine these to two arrays into a single two-dimensional array.
There are 5 inventory types:
Protein
Dairy
Grains
Vegetables
Fruits
Your program should allow the user the following options:
Enter a Donation
Enter a Request
Fulfill Requests
Print status report
Exit
Option 1:
Ask the user for the inventory type and amount of the donation to be made. When the donation
has been added to the donations table, the program should notify the user by printing out
“Donation Added”.
Option 2:
Ask the user for the inventory type and amount of the request to be made. When the request has
been added to the requests table, the program should notify the user by printing out “Request
Added”.
Option 3:
Check each type of inventory in the Request Table.
For each item that has a value in the request table, check to see if there is inventory of the same
type in the donations table.
If there are no donations of that type, print “ requests cannot be fulfilled.” Replace with the
correct inventory type (Dairy, Fruit, etc.).
If there is some inventory in the donations table, but not enough to process all requests, print “
requests will be partially fulfilled”. Reduce both the donation and request amounts based on how
much of the request was able to be fulfilled. Replace with the correct inventory type (Dairy,
Fruit, etc.).
If there is enough inventory to fulfill the request, print “type x> requests will be fulfilled.”
Reduce the appropriate amount from the Donations Table and remove the amount from the
Request Table. Replace with the correct inventory type (Dairy, Fruit, etc.).
Option 4:
Print both tables, indicating which is for donations and which is for requests.
After options 1, 2, 3, and 4 prompt the user with the menu again.
Option 5:
Print “Thank you for running our system!” and then the program exits.
Do not prompt the user for any more information.
This is the code that needs to output:
Welcome to the Food Bank Management Program!
What would you like to do?
1. Enter a Donation
2. Enter a Request
3. Fulfill Requests
4. Print status report
5. Exit
1
What donation type would you like to enter?
0. Protein
1. Dairy
2. Grains
3. Vegetables
4. Fruits
0
How many would you like to enter? 5
Donation Added.
What would you like to do?
1. Enter a Donation
2. Enter a Request
3. Fulfill Requests
4. Print status report
5. Exit
1
What donation type would you like to enter?
0. Protein
1. Dairy
2. Grains
3. Vegetables
4. Fruits
2
How many would you like to enter? 10
Donation Added.
What would you like to do?
1. Enter a Donation
2. Enter a Request
3. Fulfill Requests
4. Print status report
5. Exit
1
What donation type would you like to enter?
0. Protein
1. Dairy
2. Grains
3. Vegetables
4. Fruits
4
How many would you like to enter? 7
Donation Added.
What would you like to do?
1. Enter a Donation
2. Enter a Request
3. Fulfill Requests
4. Print status report
5. Exit
4
Protein: Donations: 5 Requests: 0
Dairy: Donations: 0 Requests: 0
Grains: Donations: 10 Requests: 0
Vegetables: Donations: 0 Requests: 0
Fruits: Donations: 7 Requests: 0
What would you like to do?
1. Enter a Donation
2. Enter a Request
3. Fulfill Requests
4. Print status report
5. Exit
1
What donation type would you like to enter?
0. Protein
1. Dairy
2. Grains
3. Vegetables
4. Fruits
0
How many would you like to enter? 3
Donation Added.
What would you like to do?
1. Enter a Donation
2. Enter a Request
3. Fulfill Requests
4. Print status report
5. Exit
2
What would you like to request?
0. Protein
1. Dairy
2. Grains
3. Vegetables
4. Fruits
1
How many would you like to request? 5
Request Added.
What would you like to do?
1. Enter a Donation
2. Enter a Request
3. Fulfill Requests
4. Print status report
5. Exit
2
What would you like to request?
0. Protein
1. Dairy
2. Grains
3. Vegetables
4. Fruits
2
How many would you like to request? 15
Request Added.
What would you like to do?
1. Enter a Donation
2. Enter a Request
3. Fulfill Requests
4. Print status report
5. Exit
4
Protein: Donations: 8 Requests: 0
Dairy: Donations: 0 Requests: 5
Grains: Donations: 10 Requests: 15
Vegetables: Donations: 0 Requests: 0
Fruits: Donations: 7 Requests: 0
What would you like to do?
1. Enter a Donation
2. Enter a Request
3. Fulfill Requests
4. Print status report
5. Exit
3
Dairy requests cannot be fulfilled.
Grain requests will be partially fulfilled.
What would you like to do?
1. Enter a Donation
2. Enter a Request
3. Fulfill Requests
4. Print status report
5. Exit
4
Protein: Donations: 8 Requests: 0
Dairy: Donations: 0 Requests: 5
Grains: Donations: 0 Requests: 5
Vegetables: Donations: 0 Requests: 0
Fruits: Donations: 7 Requests: 0
What would you like to do?
1. Enter a Donation
2. Enter a Request
3. Fulfill Requests
4. Print status report
5. Exit
6
Sorry, that was not a valid input.
What would you like to do?
1. Enter a Donation
2. Enter a Request
3. Fulfill Requests
4. Print status report
5. Exit
5
Thank you for running our system!
This is the code I have so far:
#include
int main() {
int choice, i, number, type;
int temp_donations[5] = {0};
int donations[5] = {0};
int request[5] = {0};
char TYPES[5][20] = {"Protein", "Dairy", "Grains", "Vegetables", "Fruits"};
printf("Welcome to the Food Bank Management Program! ");
//Give and ask for the user's choice
printf("What would you like to do? ");
printf("t1. Enter a Donation ");
printf("t2. Enter a Request ");
printf("t3. Fulfill Request ");
printf("t4. Print status report ");
printf("t5. Exit ");
scanf("%d", &choice);
printf(" ");
//Print if choice is greater than 5 or less than 1
if(choice > 5 || choice < 1)
printf("Sorry, that was not a valid input.  ");
while (choice != 5) {
switch (choice) {
case 1:
//ask user the type of food they would like to donate
printf(" What donation type would you like to enter? ");
number = 0;
for(i=0; i<5; i++){
printf("t%d. %s ",number, TYPES[i]);
number += 1;
}
//user input for food type and amount to donate
scanf("%d", &type);
printf(" How many would you like to enter? ");
scanf("%d", &donations[type]);
printf("Donation Added.  ");
break;
case 2:
//ask user the type of food they would like to request
printf(" What would you like to request? ");
number = 0;
for(i=0; i<5; i++){
printf("t%d. %s ",number, TYPES[i]);
number += 1;
}
//user input for request and amount requested
scanf("%d", &type);
printf(" How many would you like to request? ");
scanf("%d", &request[type]);
printf("Request Added!  ");
break;
case 3:
//go through foods and fulfill the requests if possible
for(i=0; i<5; i++){
if (request[i] > donations[i] && donations[i] == 0)
printf("%s requests cannot be fulfilled. ", TYPES[i]);
else if (request[i] > donations[i]){
printf("%s requests will be partially fulfilled. ", TYPES[i]);
temp_donations[i] = donations[i];
donations[i] -= donations[i];
request[i] -= temp_donations[i];
}
else {
donations[i] -= request[i];
request[i] -= request[i];
}
}
printf(" ");
break;
case 4:
//print table of current donations and requests
for(i=0; i<5; i++){
printf("t%-10s: Donations: %-2d Requests: %-2d ", TYPES[i], donations[i], request[i]);
}
printf(" ");
break;
}
//reask for user's choice
printf("What would you like to do? ");
printf("t1. Enter a Donation ");
printf("t2. Enter a Request ");
printf("t3. Fulfill Request ");
printf("t4. Print status report ");
printf("t5. Exit ");
scanf("%d", &choice);
printf(" ");
if(choice > 5 || choice < 1)
printf("Sorry, that was not a valid input.  ");
}
printf("Thank you for running our system! ");
return 0;
}
It seems to work mostly but I cannot get the fulfill requests to properly work. It will only state
that the Dairy requests cannot be fulfilled and will not bring up the Grain Requests like in the
example. I do not understand what to program in to get it to resemble the output.
Solution
#include
int main() {
int choice, i, number, type;
int temp_donations[5] = {0};
int donations[5] = {0};
int request[5] = {0};
int temp;
char TYPES[5][20] = {"Protein", "Dairy", "Grains", "Vegetables", "Fruits"};
printf("Welcome to the Food Bank Management Program! ");
//Give and ask for the user's choice
printf("What would you like to do? ");
printf("t1. Enter a Donation ");
printf("t2. Enter a Request ");
printf("t3. Fulfill Request ");
printf("t4. Print status report ");
printf("t5. Exit ");
scanf("%d", &choice);
printf(" ");
//Print if choice is greater than 5 or less than 1
if(choice > 5 || choice < 1)
printf("Sorry, that was not a valid input.  ");
while (choice != 5) {
switch (choice) {
case 1:
//ask user the type of food they would like to donate
printf(" What donation type would you like to enter? ");
number = 0;
for(i=0; i<5; i++){
printf("t%d. %s ",number, TYPES[i]);
number += 1;
}
//user input for food type and amount to donate
scanf("%d", &type);
printf(" How many would you like to enter? ");
scanf("%d", &temp); // you need to add it to existing donations, not replace the existing
donations
donations[type] += temp;
printf("Donation Added.  ");
break;
case 2:
//ask user the type of food they would like to request
printf(" What would you like to request? ");
number = 0;
for(i=0; i<5; i++){
printf("t%d. %s ",number, TYPES[i]);
number += 1;
}
//user input for request and amount requested
scanf("%d", &type);
printf(" How many would you like to request? ");
scanf("%d", &temp); // you need to add it to existing requests, not replace the existing requests
request[type] += temp;
printf("Request Added!  ");
break;
case 3:
//go through foods and fulfill the requests if possible
for(i=0; i<5; i++){
if (request[i] > donations[i] && donations[i] == 0)
printf("%s requests cannot be fulfilled. ", TYPES[i]);
else if (request[i] > donations[i]){
printf("%s requests will be partially fulfilled. ", TYPES[i]);
temp_donations[i] = donations[i];
donations[i] -= donations[i];
request[i] -= temp_donations[i];
}
else {
donations[i] -= request[i];
request[i] -= request[i];
}
}
printf(" ");
break;
case 4:
//print table of current donations and requests
for(i=0; i<5; i++){
printf("t%-10s: Donations: %-2d Requests: %-2d ", TYPES[i], donations[i],
request[i]);
}
printf(" ");
break;
}
//reask for user's choice
printf("What would you like to do? ");
printf("t1. Enter a Donation ");
printf("t2. Enter a Request ");
printf("t3. Fulfill Request ");
printf("t4. Print status report ");
printf("t5. Exit ");
scanf("%d", &choice);
printf(" ");
if(choice > 5 || choice < 1)
printf("Sorry, that was not a valid input.  ");
}
printf("Thank you for running our system! ");
return 0;
}

More Related Content

Similar to NEED HELP ON C HOMEWORKIntroduction Programmers for a Better Tomo.pdf

Custom Research Paper Writing Service By Khan Jo
Custom Research Paper Writing Service By Khan JoCustom Research Paper Writing Service By Khan Jo
Custom Research Paper Writing Service By Khan Jo
Scott Bou
 
Smart Resturant
Smart ResturantSmart Resturant
Smart Resturant
Sandeep Balijepalli
 
Software users guide 2 19 15
Software users guide 2 19 15Software users guide 2 19 15
Software users guide 2 19 15mj1748
 
Smart restaurant
Smart restaurantSmart restaurant
Smart restaurant
Sandeep Balijepalli
 
Smart restaurant
Smart restaurantSmart restaurant
Smart restaurant
Sandeep Balijepalli
 
Foodole : One tap can feed one life
Foodole : One tap can feed one lifeFoodole : One tap can feed one life
Foodole : One tap can feed one life
Zubeen Lapsiwala
 
Why build it when you can utilize e tapestry's standard reports - eTapestry U...
Why build it when you can utilize e tapestry's standard reports - eTapestry U...Why build it when you can utilize e tapestry's standard reports - eTapestry U...
Why build it when you can utilize e tapestry's standard reports - eTapestry U...Blackbaud
 
Blood donation registration Form
Blood donation registration FormBlood donation registration Form
Blood donation registration Form
Med E Guru
 
Omo digital simulation and lessons
Omo digital simulation and lessons Omo digital simulation and lessons
Omo digital simulation and lessons
KarenChenoaSergent
 
Demographic Assessment ProjectNURS 4404 Community Health .docx
Demographic Assessment ProjectNURS 4404 Community Health .docxDemographic Assessment ProjectNURS 4404 Community Health .docx
Demographic Assessment ProjectNURS 4404 Community Health .docx
simonithomas47935
 
Descriptive Essay For 7Th Grade
Descriptive Essay For 7Th GradeDescriptive Essay For 7Th Grade
Descriptive Essay For 7Th Grade
Katy Langley
 
Grant Writing Basics for Food Systems Projects
Grant Writing Basics for Food Systems ProjectsGrant Writing Basics for Food Systems Projects
Grant Writing Basics for Food Systems Projects
Community and Regional Food Systems
 
Admission Essay How To Persuasive Essay. Online assignment writing service.
Admission Essay How To Persuasive Essay. Online assignment writing service.Admission Essay How To Persuasive Essay. Online assignment writing service.
Admission Essay How To Persuasive Essay. Online assignment writing service.
Laura Scott
 
Food donation project report I
Food donation project report IFood donation project report I
Food donation project report I
Dhananjaysinh Jhala
 
Best Thesis Writing Service. Online assignment writing service.
Best Thesis Writing Service. Online assignment writing service.Best Thesis Writing Service. Online assignment writing service.
Best Thesis Writing Service. Online assignment writing service.
James Heller
 
Veterans Day Writing Paper Pack Freebie By Denise
Veterans Day Writing Paper Pack Freebie By DeniseVeterans Day Writing Paper Pack Freebie By Denise
Veterans Day Writing Paper Pack Freebie By Denise
Rebecca Buono
 
Student Turnitin Feedback Studio tutorial_20240306 (1).pdf
Student Turnitin Feedback Studio tutorial_20240306 (1).pdfStudent Turnitin Feedback Studio tutorial_20240306 (1).pdf
Student Turnitin Feedback Studio tutorial_20240306 (1).pdf
yonseilibrary
 
ClinicPro Online QuickStart Guide
ClinicPro Online QuickStart GuideClinicPro Online QuickStart Guide
ClinicPro Online QuickStart Guide
Louell Saavedra
 
What Works?
What Works?What Works?
What Works?Goodzuma
 

Similar to NEED HELP ON C HOMEWORKIntroduction Programmers for a Better Tomo.pdf (20)

Custom Research Paper Writing Service By Khan Jo
Custom Research Paper Writing Service By Khan JoCustom Research Paper Writing Service By Khan Jo
Custom Research Paper Writing Service By Khan Jo
 
Smart Resturant
Smart ResturantSmart Resturant
Smart Resturant
 
Software users guide 2 19 15
Software users guide 2 19 15Software users guide 2 19 15
Software users guide 2 19 15
 
Smart restaurant
Smart restaurantSmart restaurant
Smart restaurant
 
Smart restaurant
Smart restaurantSmart restaurant
Smart restaurant
 
Foodole : One tap can feed one life
Foodole : One tap can feed one lifeFoodole : One tap can feed one life
Foodole : One tap can feed one life
 
Why build it when you can utilize e tapestry's standard reports - eTapestry U...
Why build it when you can utilize e tapestry's standard reports - eTapestry U...Why build it when you can utilize e tapestry's standard reports - eTapestry U...
Why build it when you can utilize e tapestry's standard reports - eTapestry U...
 
Blood donation registration Form
Blood donation registration FormBlood donation registration Form
Blood donation registration Form
 
Omo digital simulation and lessons
Omo digital simulation and lessons Omo digital simulation and lessons
Omo digital simulation and lessons
 
Demographic Assessment ProjectNURS 4404 Community Health .docx
Demographic Assessment ProjectNURS 4404 Community Health .docxDemographic Assessment ProjectNURS 4404 Community Health .docx
Demographic Assessment ProjectNURS 4404 Community Health .docx
 
Descriptive Essay For 7Th Grade
Descriptive Essay For 7Th GradeDescriptive Essay For 7Th Grade
Descriptive Essay For 7Th Grade
 
2015 day 2
2015 day 22015 day 2
2015 day 2
 
Grant Writing Basics for Food Systems Projects
Grant Writing Basics for Food Systems ProjectsGrant Writing Basics for Food Systems Projects
Grant Writing Basics for Food Systems Projects
 
Admission Essay How To Persuasive Essay. Online assignment writing service.
Admission Essay How To Persuasive Essay. Online assignment writing service.Admission Essay How To Persuasive Essay. Online assignment writing service.
Admission Essay How To Persuasive Essay. Online assignment writing service.
 
Food donation project report I
Food donation project report IFood donation project report I
Food donation project report I
 
Best Thesis Writing Service. Online assignment writing service.
Best Thesis Writing Service. Online assignment writing service.Best Thesis Writing Service. Online assignment writing service.
Best Thesis Writing Service. Online assignment writing service.
 
Veterans Day Writing Paper Pack Freebie By Denise
Veterans Day Writing Paper Pack Freebie By DeniseVeterans Day Writing Paper Pack Freebie By Denise
Veterans Day Writing Paper Pack Freebie By Denise
 
Student Turnitin Feedback Studio tutorial_20240306 (1).pdf
Student Turnitin Feedback Studio tutorial_20240306 (1).pdfStudent Turnitin Feedback Studio tutorial_20240306 (1).pdf
Student Turnitin Feedback Studio tutorial_20240306 (1).pdf
 
ClinicPro Online QuickStart Guide
ClinicPro Online QuickStart GuideClinicPro Online QuickStart Guide
ClinicPro Online QuickStart Guide
 
What Works?
What Works?What Works?
What Works?
 

More from omarionmatzmcwill497

CenTable - Requirements Specification CenTable is a system for creati.pdf
CenTable - Requirements Specification CenTable is a system for creati.pdfCenTable - Requirements Specification CenTable is a system for creati.pdf
CenTable - Requirements Specification CenTable is a system for creati.pdf
omarionmatzmcwill497
 
Are silenced genes associated with high or low levels of DNA methyla.pdf
Are silenced genes associated with high or low levels of DNA methyla.pdfAre silenced genes associated with high or low levels of DNA methyla.pdf
Are silenced genes associated with high or low levels of DNA methyla.pdf
omarionmatzmcwill497
 
A south facing window is 2.1 m high and 4.2 m long. A horizontal diff.pdf
A south facing window is 2.1 m high and 4.2 m long. A horizontal diff.pdfA south facing window is 2.1 m high and 4.2 m long. A horizontal diff.pdf
A south facing window is 2.1 m high and 4.2 m long. A horizontal diff.pdf
omarionmatzmcwill497
 
Write an extended summary (They say”) of Sheryl Sandbergs Lean.pdf
Write an extended summary (They say”) of Sheryl Sandbergs Lean.pdfWrite an extended summary (They say”) of Sheryl Sandbergs Lean.pdf
Write an extended summary (They say”) of Sheryl Sandbergs Lean.pdf
omarionmatzmcwill497
 
Write a program that will prompt a user to input their name(first .pdf
Write a program that will prompt a user to input their name(first .pdfWrite a program that will prompt a user to input their name(first .pdf
Write a program that will prompt a user to input their name(first .pdf
omarionmatzmcwill497
 
With a blow count of 14 the density of the soil is Select one 15e bit.pdf
With a blow count of 14 the density of the soil is Select one 15e bit.pdfWith a blow count of 14 the density of the soil is Select one 15e bit.pdf
With a blow count of 14 the density of the soil is Select one 15e bit.pdf
omarionmatzmcwill497
 
Which process(es) can move solutes against concentration gradients (.pdf
Which process(es) can move solutes against concentration gradients (.pdfWhich process(es) can move solutes against concentration gradients (.pdf
Which process(es) can move solutes against concentration gradients (.pdf
omarionmatzmcwill497
 
What role do piRNAs play Serve as atemplate for transposon silencin.pdf
What role do piRNAs play  Serve as atemplate for transposon silencin.pdfWhat role do piRNAs play  Serve as atemplate for transposon silencin.pdf
What role do piRNAs play Serve as atemplate for transposon silencin.pdf
omarionmatzmcwill497
 
what was the PRIMARY cause of the current Greece Crisis Excessive g.pdf
what was the PRIMARY cause of the current Greece Crisis Excessive g.pdfwhat was the PRIMARY cause of the current Greece Crisis Excessive g.pdf
what was the PRIMARY cause of the current Greece Crisis Excessive g.pdf
omarionmatzmcwill497
 
Three LR circuits are made with the same resistor but different induc.pdf
Three LR circuits are made with the same resistor but different induc.pdfThree LR circuits are made with the same resistor but different induc.pdf
Three LR circuits are made with the same resistor but different induc.pdf
omarionmatzmcwill497
 
There are several things fundamentally wrong in this illustration. Po.pdf
There are several things fundamentally wrong in this illustration. Po.pdfThere are several things fundamentally wrong in this illustration. Po.pdf
There are several things fundamentally wrong in this illustration. Po.pdf
omarionmatzmcwill497
 
The poor are available to do the unpleasant jobs that no one .pdf
The poor are available to do the unpleasant jobs that no one .pdfThe poor are available to do the unpleasant jobs that no one .pdf
The poor are available to do the unpleasant jobs that no one .pdf
omarionmatzmcwill497
 
Suppose that 14 of people are left handed. If you pick two people a.pdf
Suppose that 14 of people are left handed. If you pick two people a.pdfSuppose that 14 of people are left handed. If you pick two people a.pdf
Suppose that 14 of people are left handed. If you pick two people a.pdf
omarionmatzmcwill497
 
Please help me with these General Biology 1 (Bio 111) questions. You.pdf
Please help me with these General Biology 1 (Bio 111) questions. You.pdfPlease help me with these General Biology 1 (Bio 111) questions. You.pdf
Please help me with these General Biology 1 (Bio 111) questions. You.pdf
omarionmatzmcwill497
 
Problem 14. Your probability class has 250 undergraduate students and.pdf
Problem 14. Your probability class has 250 undergraduate students and.pdfProblem 14. Your probability class has 250 undergraduate students and.pdf
Problem 14. Your probability class has 250 undergraduate students and.pdf
omarionmatzmcwill497
 
Simplify each expression. Write all ansers without using negative ex.pdf
Simplify each expression. Write all ansers without using negative ex.pdfSimplify each expression. Write all ansers without using negative ex.pdf
Simplify each expression. Write all ansers without using negative ex.pdf
omarionmatzmcwill497
 
Our understanding of genetic inheritance and the function of DNA i.pdf
Our understanding of genetic inheritance and the function of DNA i.pdfOur understanding of genetic inheritance and the function of DNA i.pdf
Our understanding of genetic inheritance and the function of DNA i.pdf
omarionmatzmcwill497
 
Please Explain. Compute the worst case time complexity of the follow.pdf
Please Explain. Compute the worst case time complexity of the follow.pdfPlease Explain. Compute the worst case time complexity of the follow.pdf
Please Explain. Compute the worst case time complexity of the follow.pdf
omarionmatzmcwill497
 
3. Variance of exponential and uniform distributions(a) Compute Va.pdf
3. Variance of exponential and uniform distributions(a) Compute Va.pdf3. Variance of exponential and uniform distributions(a) Compute Va.pdf
3. Variance of exponential and uniform distributions(a) Compute Va.pdf
omarionmatzmcwill497
 
Prove using a common notion that if P and Q are any points on a circ.pdf
Prove using a common notion that if P and Q are any points on a circ.pdfProve using a common notion that if P and Q are any points on a circ.pdf
Prove using a common notion that if P and Q are any points on a circ.pdf
omarionmatzmcwill497
 

More from omarionmatzmcwill497 (20)

CenTable - Requirements Specification CenTable is a system for creati.pdf
CenTable - Requirements Specification CenTable is a system for creati.pdfCenTable - Requirements Specification CenTable is a system for creati.pdf
CenTable - Requirements Specification CenTable is a system for creati.pdf
 
Are silenced genes associated with high or low levels of DNA methyla.pdf
Are silenced genes associated with high or low levels of DNA methyla.pdfAre silenced genes associated with high or low levels of DNA methyla.pdf
Are silenced genes associated with high or low levels of DNA methyla.pdf
 
A south facing window is 2.1 m high and 4.2 m long. A horizontal diff.pdf
A south facing window is 2.1 m high and 4.2 m long. A horizontal diff.pdfA south facing window is 2.1 m high and 4.2 m long. A horizontal diff.pdf
A south facing window is 2.1 m high and 4.2 m long. A horizontal diff.pdf
 
Write an extended summary (They say”) of Sheryl Sandbergs Lean.pdf
Write an extended summary (They say”) of Sheryl Sandbergs Lean.pdfWrite an extended summary (They say”) of Sheryl Sandbergs Lean.pdf
Write an extended summary (They say”) of Sheryl Sandbergs Lean.pdf
 
Write a program that will prompt a user to input their name(first .pdf
Write a program that will prompt a user to input their name(first .pdfWrite a program that will prompt a user to input their name(first .pdf
Write a program that will prompt a user to input their name(first .pdf
 
With a blow count of 14 the density of the soil is Select one 15e bit.pdf
With a blow count of 14 the density of the soil is Select one 15e bit.pdfWith a blow count of 14 the density of the soil is Select one 15e bit.pdf
With a blow count of 14 the density of the soil is Select one 15e bit.pdf
 
Which process(es) can move solutes against concentration gradients (.pdf
Which process(es) can move solutes against concentration gradients (.pdfWhich process(es) can move solutes against concentration gradients (.pdf
Which process(es) can move solutes against concentration gradients (.pdf
 
What role do piRNAs play Serve as atemplate for transposon silencin.pdf
What role do piRNAs play  Serve as atemplate for transposon silencin.pdfWhat role do piRNAs play  Serve as atemplate for transposon silencin.pdf
What role do piRNAs play Serve as atemplate for transposon silencin.pdf
 
what was the PRIMARY cause of the current Greece Crisis Excessive g.pdf
what was the PRIMARY cause of the current Greece Crisis Excessive g.pdfwhat was the PRIMARY cause of the current Greece Crisis Excessive g.pdf
what was the PRIMARY cause of the current Greece Crisis Excessive g.pdf
 
Three LR circuits are made with the same resistor but different induc.pdf
Three LR circuits are made with the same resistor but different induc.pdfThree LR circuits are made with the same resistor but different induc.pdf
Three LR circuits are made with the same resistor but different induc.pdf
 
There are several things fundamentally wrong in this illustration. Po.pdf
There are several things fundamentally wrong in this illustration. Po.pdfThere are several things fundamentally wrong in this illustration. Po.pdf
There are several things fundamentally wrong in this illustration. Po.pdf
 
The poor are available to do the unpleasant jobs that no one .pdf
The poor are available to do the unpleasant jobs that no one .pdfThe poor are available to do the unpleasant jobs that no one .pdf
The poor are available to do the unpleasant jobs that no one .pdf
 
Suppose that 14 of people are left handed. If you pick two people a.pdf
Suppose that 14 of people are left handed. If you pick two people a.pdfSuppose that 14 of people are left handed. If you pick two people a.pdf
Suppose that 14 of people are left handed. If you pick two people a.pdf
 
Please help me with these General Biology 1 (Bio 111) questions. You.pdf
Please help me with these General Biology 1 (Bio 111) questions. You.pdfPlease help me with these General Biology 1 (Bio 111) questions. You.pdf
Please help me with these General Biology 1 (Bio 111) questions. You.pdf
 
Problem 14. Your probability class has 250 undergraduate students and.pdf
Problem 14. Your probability class has 250 undergraduate students and.pdfProblem 14. Your probability class has 250 undergraduate students and.pdf
Problem 14. Your probability class has 250 undergraduate students and.pdf
 
Simplify each expression. Write all ansers without using negative ex.pdf
Simplify each expression. Write all ansers without using negative ex.pdfSimplify each expression. Write all ansers without using negative ex.pdf
Simplify each expression. Write all ansers without using negative ex.pdf
 
Our understanding of genetic inheritance and the function of DNA i.pdf
Our understanding of genetic inheritance and the function of DNA i.pdfOur understanding of genetic inheritance and the function of DNA i.pdf
Our understanding of genetic inheritance and the function of DNA i.pdf
 
Please Explain. Compute the worst case time complexity of the follow.pdf
Please Explain. Compute the worst case time complexity of the follow.pdfPlease Explain. Compute the worst case time complexity of the follow.pdf
Please Explain. Compute the worst case time complexity of the follow.pdf
 
3. Variance of exponential and uniform distributions(a) Compute Va.pdf
3. Variance of exponential and uniform distributions(a) Compute Va.pdf3. Variance of exponential and uniform distributions(a) Compute Va.pdf
3. Variance of exponential and uniform distributions(a) Compute Va.pdf
 
Prove using a common notion that if P and Q are any points on a circ.pdf
Prove using a common notion that if P and Q are any points on a circ.pdfProve using a common notion that if P and Q are any points on a circ.pdf
Prove using a common notion that if P and Q are any points on a circ.pdf
 

Recently uploaded

Fresher’s Quiz 2023 at GMC Nizamabad.pptx
Fresher’s Quiz 2023 at GMC Nizamabad.pptxFresher’s Quiz 2023 at GMC Nizamabad.pptx
Fresher’s Quiz 2023 at GMC Nizamabad.pptx
SriSurya50
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
kitab khulasah nurul yaqin jilid 1 - 2.pptx
kitab khulasah nurul yaqin jilid 1 - 2.pptxkitab khulasah nurul yaqin jilid 1 - 2.pptx
kitab khulasah nurul yaqin jilid 1 - 2.pptx
datarid22
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
Delivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and TrainingDelivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and Training
AG2 Design
 
What is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptxWhat is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptx
christianmathematics
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 

Recently uploaded (20)

Fresher’s Quiz 2023 at GMC Nizamabad.pptx
Fresher’s Quiz 2023 at GMC Nizamabad.pptxFresher’s Quiz 2023 at GMC Nizamabad.pptx
Fresher’s Quiz 2023 at GMC Nizamabad.pptx
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
kitab khulasah nurul yaqin jilid 1 - 2.pptx
kitab khulasah nurul yaqin jilid 1 - 2.pptxkitab khulasah nurul yaqin jilid 1 - 2.pptx
kitab khulasah nurul yaqin jilid 1 - 2.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
Delivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and TrainingDelivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and Training
 
What is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptxWhat is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptx
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 

NEED HELP ON C HOMEWORKIntroduction Programmers for a Better Tomo.pdf

  • 1. NEED HELP ON C HOMEWORK Introduction: Programmers for a Better Tomorrow Programmers for a Better Tomorrow is an organization dedicated to helping charities, medical societies, and scholarship organizations manage various tasks so that they can focus on making the world a better place! They have asked you and your classmates to help them develop some new programs to benefit their organizations. Problem: Food Bank Management (foodbank.c) Programmers for a Better Tomorrow is now in partnership with a local Food Bank which distributes food items to people in need. People come in to a Food Bank and make their donations, and others might come in to make a request for any food item they want. A Food Bank Management Program is used to keep track of the stock the Food Bank has (i.e., the donations), keep a record of requests that come in, fulfilling requests and printing the status report which consists of the amount of stock present in the food bank and the requests that are not yet fulfilled. The program will require you to make at least one array. You may choose to make multiple one- dimensional arrays: one to serve as a Donations Table and one to serve as a Request Table. The index of the array will represent the inventory type. The value in the array will represent the amount present or needed of that type. You may, instead, choose to combine these to two arrays into a single two-dimensional array. There are 5 inventory types: Protein Dairy Grains Vegetables Fruits Your program should allow the user the following options: Enter a Donation Enter a Request Fulfill Requests Print status report Exit Option 1: Ask the user for the inventory type and amount of the donation to be made. When the donation has been added to the donations table, the program should notify the user by printing out “Donation Added”.
  • 2. Option 2: Ask the user for the inventory type and amount of the request to be made. When the request has been added to the requests table, the program should notify the user by printing out “Request Added”. Option 3: Check each type of inventory in the Request Table. For each item that has a value in the request table, check to see if there is inventory of the same type in the donations table. If there are no donations of that type, print “ requests cannot be fulfilled.” Replace with the correct inventory type (Dairy, Fruit, etc.). If there is some inventory in the donations table, but not enough to process all requests, print “ requests will be partially fulfilled”. Reduce both the donation and request amounts based on how much of the request was able to be fulfilled. Replace with the correct inventory type (Dairy, Fruit, etc.). If there is enough inventory to fulfill the request, print “type x> requests will be fulfilled.” Reduce the appropriate amount from the Donations Table and remove the amount from the Request Table. Replace with the correct inventory type (Dairy, Fruit, etc.). Option 4: Print both tables, indicating which is for donations and which is for requests. After options 1, 2, 3, and 4 prompt the user with the menu again. Option 5: Print “Thank you for running our system!” and then the program exits. Do not prompt the user for any more information. This is the code that needs to output: Welcome to the Food Bank Management Program! What would you like to do? 1. Enter a Donation 2. Enter a Request 3. Fulfill Requests 4. Print status report 5. Exit 1 What donation type would you like to enter? 0. Protein 1. Dairy 2. Grains
  • 3. 3. Vegetables 4. Fruits 0 How many would you like to enter? 5 Donation Added. What would you like to do? 1. Enter a Donation 2. Enter a Request 3. Fulfill Requests 4. Print status report 5. Exit 1 What donation type would you like to enter? 0. Protein 1. Dairy 2. Grains 3. Vegetables 4. Fruits 2 How many would you like to enter? 10 Donation Added. What would you like to do? 1. Enter a Donation 2. Enter a Request 3. Fulfill Requests 4. Print status report 5. Exit 1 What donation type would you like to enter? 0. Protein 1. Dairy 2. Grains 3. Vegetables 4. Fruits 4 How many would you like to enter? 7
  • 4. Donation Added. What would you like to do? 1. Enter a Donation 2. Enter a Request 3. Fulfill Requests 4. Print status report 5. Exit 4 Protein: Donations: 5 Requests: 0 Dairy: Donations: 0 Requests: 0 Grains: Donations: 10 Requests: 0 Vegetables: Donations: 0 Requests: 0 Fruits: Donations: 7 Requests: 0 What would you like to do? 1. Enter a Donation 2. Enter a Request 3. Fulfill Requests 4. Print status report 5. Exit 1 What donation type would you like to enter? 0. Protein 1. Dairy 2. Grains 3. Vegetables 4. Fruits 0 How many would you like to enter? 3 Donation Added. What would you like to do? 1. Enter a Donation 2. Enter a Request 3. Fulfill Requests 4. Print status report 5. Exit 2
  • 5. What would you like to request? 0. Protein 1. Dairy 2. Grains 3. Vegetables 4. Fruits 1 How many would you like to request? 5 Request Added. What would you like to do? 1. Enter a Donation 2. Enter a Request 3. Fulfill Requests 4. Print status report 5. Exit 2 What would you like to request? 0. Protein 1. Dairy 2. Grains 3. Vegetables 4. Fruits 2 How many would you like to request? 15 Request Added. What would you like to do? 1. Enter a Donation 2. Enter a Request 3. Fulfill Requests 4. Print status report 5. Exit 4 Protein: Donations: 8 Requests: 0 Dairy: Donations: 0 Requests: 5 Grains: Donations: 10 Requests: 15 Vegetables: Donations: 0 Requests: 0
  • 6. Fruits: Donations: 7 Requests: 0 What would you like to do? 1. Enter a Donation 2. Enter a Request 3. Fulfill Requests 4. Print status report 5. Exit 3 Dairy requests cannot be fulfilled. Grain requests will be partially fulfilled. What would you like to do? 1. Enter a Donation 2. Enter a Request 3. Fulfill Requests 4. Print status report 5. Exit 4 Protein: Donations: 8 Requests: 0 Dairy: Donations: 0 Requests: 5 Grains: Donations: 0 Requests: 5 Vegetables: Donations: 0 Requests: 0 Fruits: Donations: 7 Requests: 0 What would you like to do? 1. Enter a Donation 2. Enter a Request 3. Fulfill Requests 4. Print status report 5. Exit 6 Sorry, that was not a valid input. What would you like to do? 1. Enter a Donation 2. Enter a Request 3. Fulfill Requests 4. Print status report 5. Exit
  • 7. 5 Thank you for running our system! This is the code I have so far: #include int main() { int choice, i, number, type; int temp_donations[5] = {0}; int donations[5] = {0}; int request[5] = {0}; char TYPES[5][20] = {"Protein", "Dairy", "Grains", "Vegetables", "Fruits"}; printf("Welcome to the Food Bank Management Program! "); //Give and ask for the user's choice printf("What would you like to do? "); printf("t1. Enter a Donation "); printf("t2. Enter a Request "); printf("t3. Fulfill Request "); printf("t4. Print status report "); printf("t5. Exit "); scanf("%d", &choice); printf(" "); //Print if choice is greater than 5 or less than 1 if(choice > 5 || choice < 1) printf("Sorry, that was not a valid input. "); while (choice != 5) { switch (choice) { case 1: //ask user the type of food they would like to donate printf(" What donation type would you like to enter? "); number = 0; for(i=0; i<5; i++){ printf("t%d. %s ",number, TYPES[i]); number += 1; } //user input for food type and amount to donate scanf("%d", &type); printf(" How many would you like to enter? ");
  • 8. scanf("%d", &donations[type]); printf("Donation Added. "); break; case 2: //ask user the type of food they would like to request printf(" What would you like to request? "); number = 0; for(i=0; i<5; i++){ printf("t%d. %s ",number, TYPES[i]); number += 1; } //user input for request and amount requested scanf("%d", &type); printf(" How many would you like to request? "); scanf("%d", &request[type]); printf("Request Added! "); break; case 3: //go through foods and fulfill the requests if possible for(i=0; i<5; i++){ if (request[i] > donations[i] && donations[i] == 0) printf("%s requests cannot be fulfilled. ", TYPES[i]); else if (request[i] > donations[i]){ printf("%s requests will be partially fulfilled. ", TYPES[i]); temp_donations[i] = donations[i]; donations[i] -= donations[i]; request[i] -= temp_donations[i]; } else { donations[i] -= request[i]; request[i] -= request[i]; } } printf(" "); break; case 4:
  • 9. //print table of current donations and requests for(i=0; i<5; i++){ printf("t%-10s: Donations: %-2d Requests: %-2d ", TYPES[i], donations[i], request[i]); } printf(" "); break; } //reask for user's choice printf("What would you like to do? "); printf("t1. Enter a Donation "); printf("t2. Enter a Request "); printf("t3. Fulfill Request "); printf("t4. Print status report "); printf("t5. Exit "); scanf("%d", &choice); printf(" "); if(choice > 5 || choice < 1) printf("Sorry, that was not a valid input. "); } printf("Thank you for running our system! "); return 0; } It seems to work mostly but I cannot get the fulfill requests to properly work. It will only state that the Dairy requests cannot be fulfilled and will not bring up the Grain Requests like in the example. I do not understand what to program in to get it to resemble the output. Solution #include int main() { int choice, i, number, type; int temp_donations[5] = {0}; int donations[5] = {0}; int request[5] = {0}; int temp; char TYPES[5][20] = {"Protein", "Dairy", "Grains", "Vegetables", "Fruits"};
  • 10. printf("Welcome to the Food Bank Management Program! "); //Give and ask for the user's choice printf("What would you like to do? "); printf("t1. Enter a Donation "); printf("t2. Enter a Request "); printf("t3. Fulfill Request "); printf("t4. Print status report "); printf("t5. Exit "); scanf("%d", &choice); printf(" "); //Print if choice is greater than 5 or less than 1 if(choice > 5 || choice < 1) printf("Sorry, that was not a valid input. "); while (choice != 5) { switch (choice) { case 1: //ask user the type of food they would like to donate printf(" What donation type would you like to enter? "); number = 0; for(i=0; i<5; i++){ printf("t%d. %s ",number, TYPES[i]); number += 1; } //user input for food type and amount to donate scanf("%d", &type); printf(" How many would you like to enter? "); scanf("%d", &temp); // you need to add it to existing donations, not replace the existing donations donations[type] += temp; printf("Donation Added. "); break; case 2: //ask user the type of food they would like to request printf(" What would you like to request? "); number = 0; for(i=0; i<5; i++){
  • 11. printf("t%d. %s ",number, TYPES[i]); number += 1; } //user input for request and amount requested scanf("%d", &type); printf(" How many would you like to request? "); scanf("%d", &temp); // you need to add it to existing requests, not replace the existing requests request[type] += temp; printf("Request Added! "); break; case 3: //go through foods and fulfill the requests if possible for(i=0; i<5; i++){ if (request[i] > donations[i] && donations[i] == 0) printf("%s requests cannot be fulfilled. ", TYPES[i]); else if (request[i] > donations[i]){ printf("%s requests will be partially fulfilled. ", TYPES[i]); temp_donations[i] = donations[i]; donations[i] -= donations[i]; request[i] -= temp_donations[i]; } else { donations[i] -= request[i]; request[i] -= request[i]; } } printf(" "); break; case 4: //print table of current donations and requests for(i=0; i<5; i++){ printf("t%-10s: Donations: %-2d Requests: %-2d ", TYPES[i], donations[i], request[i]); } printf(" "); break;
  • 12. } //reask for user's choice printf("What would you like to do? "); printf("t1. Enter a Donation "); printf("t2. Enter a Request "); printf("t3. Fulfill Request "); printf("t4. Print status report "); printf("t5. Exit "); scanf("%d", &choice); printf(" "); if(choice > 5 || choice < 1) printf("Sorry, that was not a valid input. "); } printf("Thank you for running our system! "); return 0; }