SlideShare a Scribd company logo
1 of 12
Download to read offline
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.
Sample Data Items
You may wish to use these data structures to help you solve the problem.
int status[2][5];
char TYPES[5][20] = {“PROTEIN”, “DAIRY”, “GRAINS”, “VEGETABLES”, “FRUITS”};
The values in “TYPES” are strings and may be printed with %s. For example, to print “DAIRY”
we could use printf(“%s”, TYPES[1]);
Input Specification
All inputs will be greater than or equal to zero
Output Specification
View the sample run to see how the output tables should be formatted.
Output Sample
Below is a sample output of running the program. Note that this sample is NOT a comprehensive
test. You should test your program with different data than is shown here based on the
specifications given above.
In the sample run below, for clarity and ease of reading, the user input is given in italics while
the program output is in bold. (Note: When you actually run your program no bold or italics
should appear at all. These are simply used in this description for clarity’s sake.)
Sample Run
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!
Solution
/**
C program that prints a menu to choose type of choice
and type of food that to donate or request or fullfill or print
status.
*/
//foodbank.c
#include
#include
#include
//global variables
int status[2][5];
char TYPES[5][20] = {"PROTEIN", "DAIRY", "GRAINS", "VEGETABLES",
"FRUITS"};
//function prototypes
int menu();
int type();
void printStatus();
//main funtion
int main()
{
bool repeat=true;
int donation=0;
int request=0;
int donationType=0;
while(repeat)
{
int ch=menu();
switch(ch)
{
case 1:
donationType=type();
printf(" How many would you like to enter? ");
scanf("%d",&donation);
status[ch-1][donationType]+=donation;
printf(" Donation Added. ");
break;
case 2:
donationType=type();
printf(" What would you like to request? ");
scanf("%d",&request);
status[ch-1][donationType]+=request;
printf(" Donation Added. ");
break;
case 3:
for(int index=0;index<5;index++)
{
if(status[0][index]>=status[1][index])
{
status[0][index]=status[0][index]-status[1][index];
status[1][index]=0;
}
else if(status[0][index]!=0 && status[1][index]>0)
{
status[1][index]=status[1][index]-status[0][index];
status[0][index]=0;
printf("%s requests will be partially fulfilled. ",TYPES[index]);
}
else
printf("%s requests cannot be fulfilled. ", TYPES[index]);
}
break;
case 4:
printStatus();
break;
case 5:
getch();
printf(" Thank you for running our system!");
exit(0);
}
}
getch();
return 0;
}
//print status of food bank
void printStatus()
{
int i;
for(i=0;i<5;i++)
{
printf("%-15s Donations: %d Request: %d ",
TYPES[i],status[0][i],status[1][i]);
}
}
//function that prompt for type of choice from user
int menu()
{
int choice;
do
{
printf("Welcome to the Food Bank Management Program! ");
printf("What would you like to do? ");
printf("t1. Enter a Donation ");
printf("t2. Enter a Request ");
printf("t3. Fulfill Requests ");
printf("t4. Print status report ");
printf("t5. Exit ");
scanf("%d",&choice);
}while(choice <1 || choice>5);
return choice;
}
//function that prompts user to select the type of food
int type()
{
int donationType;
do
{
printf(" What donation type would you like to enter? ");
printf("t0. Protein ");
printf("t1. Dairy ");
printf("t2. Grains ");
printf("t3. Vegetables ");
printf("t4. Fruits ");
scanf("%d",&donationType);
}while(donationType<0 || donationType>4);
return donationType;
}
------------------------------------------
Sample 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.
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
2
How many would you like to enter? 10
Donation Added.
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
4
PROTEIN Donations: 5 Request: 0
DAIRY Donations: 0 Request: 0
GRAINS Donations: 10 Request: 0
VEGETABLES Donations: 0 Request: 0
FRUITS Donations: 0 Request: 0
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
4
PROTEIN Donations: 5 Request: 0
DAIRY Donations: 0 Request: 0
GRAINS Donations: 10 Request: 0
VEGETABLES Donations: 0 Request: 0
FRUITS Donations: 0 Request: 0
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

More Related Content

Similar to Introduction Programmers for a Better TomorrowProgrammers for a B.pdf

Apple INNOHORT 2015 - ISHS Symposium - Avignon University, France
Apple INNOHORT 2015 - ISHS Symposium - Avignon University, FranceApple INNOHORT 2015 - ISHS Symposium - Avignon University, France
Apple INNOHORT 2015 - ISHS Symposium - Avignon University, France
Hector German Rodriguez
 
1 SimplyMap for Public Health Cecilia Smith,.docx
1  SimplyMap for Public Health  Cecilia Smith,.docx1  SimplyMap for Public Health  Cecilia Smith,.docx
1 SimplyMap for Public Health Cecilia Smith,.docx
honey725342
 
AI Cycle and data sc- CH-4 (4).pptx
AI Cycle and data sc- CH-4 (4).pptxAI Cycle and data sc- CH-4 (4).pptx
AI Cycle and data sc- CH-4 (4).pptx
siddhichaddha2
 
AI Cycle and data sc- CH-4 (3).pptx
AI Cycle and data sc- CH-4 (3).pptxAI Cycle and data sc- CH-4 (3).pptx
AI Cycle and data sc- CH-4 (3).pptx
siddhichaddha2
 
What Works?
What Works?What Works?
What Works?
Goodzuma
 
EMR Power Point
EMR Power PointEMR Power Point
EMR Power Point
Scottmunc
 
PSY-530 – Social Psychology Topic 3 – Attitudes and Conformi.docx
PSY-530 – Social Psychology Topic 3 – Attitudes and Conformi.docxPSY-530 – Social Psychology Topic 3 – Attitudes and Conformi.docx
PSY-530 – Social Psychology Topic 3 – Attitudes and Conformi.docx
woodruffeloisa
 
YoungerHearts_Implementation-Guide_reduced
YoungerHearts_Implementation-Guide_reducedYoungerHearts_Implementation-Guide_reduced
YoungerHearts_Implementation-Guide_reduced
Tim MacLeod, PhD
 

Similar to Introduction Programmers for a Better TomorrowProgrammers for a B.pdf (20)

Apple INNOHORT 2015 - ISHS Symposium - Avignon University, France
Apple INNOHORT 2015 - ISHS Symposium - Avignon University, FranceApple INNOHORT 2015 - ISHS Symposium - Avignon University, France
Apple INNOHORT 2015 - ISHS Symposium - Avignon University, France
 
1 SimplyMap for Public Health Cecilia Smith,.docx
1  SimplyMap for Public Health  Cecilia Smith,.docx1  SimplyMap for Public Health  Cecilia Smith,.docx
1 SimplyMap for Public Health Cecilia Smith,.docx
 
John Blue - Apps For Agriculture
John Blue - Apps For AgricultureJohn Blue - Apps For Agriculture
John Blue - Apps For Agriculture
 
Table of contents what are buyer personas ...……………
Table of contents what are buyer personas ...……………Table of contents what are buyer personas ...……………
Table of contents what are buyer personas ...……………
 
“Waste Food Management and Donation App”
“Waste Food Management and Donation App”“Waste Food Management and Donation App”
“Waste Food Management and Donation App”
 
Wintriss
WintrissWintriss
Wintriss
 
Food donation project report II
Food donation project report IIFood donation project report II
Food donation project report II
 
AI Cycle and data sc- CH-4 (4).pptx
AI Cycle and data sc- CH-4 (4).pptxAI Cycle and data sc- CH-4 (4).pptx
AI Cycle and data sc- CH-4 (4).pptx
 
AI Cycle and data sc- CH-4 (3).pptx
AI Cycle and data sc- CH-4 (3).pptxAI Cycle and data sc- CH-4 (3).pptx
AI Cycle and data sc- CH-4 (3).pptx
 
What Works?
What Works?What Works?
What Works?
 
EMR Power Point
EMR Power PointEMR Power Point
EMR Power Point
 
Sheroes Cafe - Food Ordering Application
Sheroes Cafe - Food Ordering ApplicationSheroes Cafe - Food Ordering Application
Sheroes Cafe - Food Ordering Application
 
Persuasive Essay Topics On Teenage Pregnancy
Persuasive Essay Topics On Teenage PregnancyPersuasive Essay Topics On Teenage Pregnancy
Persuasive Essay Topics On Teenage Pregnancy
 
How To Write An English Essay Introduction
How To Write An English Essay IntroductionHow To Write An English Essay Introduction
How To Write An English Essay Introduction
 
The Mla Handbook For Writers Of Research Papers
The Mla Handbook For Writers Of Research PapersThe Mla Handbook For Writers Of Research Papers
The Mla Handbook For Writers Of Research Papers
 
PSY-530 – Social Psychology Topic 3 – Attitudes and Conformi.docx
PSY-530 – Social Psychology Topic 3 – Attitudes and Conformi.docxPSY-530 – Social Psychology Topic 3 – Attitudes and Conformi.docx
PSY-530 – Social Psychology Topic 3 – Attitudes and Conformi.docx
 
YoungerHearts_Implementation-Guide_reduced
YoungerHearts_Implementation-Guide_reducedYoungerHearts_Implementation-Guide_reduced
YoungerHearts_Implementation-Guide_reduced
 
Codes for Coffee: Mock Starbucks Social Responsibility
Codes for Coffee: Mock Starbucks Social ResponsibilityCodes for Coffee: Mock Starbucks Social Responsibility
Codes for Coffee: Mock Starbucks Social Responsibility
 
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.
 
Healthcare Office Pro - Complete Overview
Healthcare Office Pro - Complete OverviewHealthcare Office Pro - Complete Overview
Healthcare Office Pro - Complete Overview
 

More from arshin9

Discuss the impact that the tonnage of sulfur or sulfuric acid recov.pdf
Discuss the impact that the tonnage of sulfur or sulfuric acid recov.pdfDiscuss the impact that the tonnage of sulfur or sulfuric acid recov.pdf
Discuss the impact that the tonnage of sulfur or sulfuric acid recov.pdf
arshin9
 
You have decided to go to graduate school for Molecular Biology (yay!.pdf
You have decided to go to graduate school for Molecular Biology (yay!.pdfYou have decided to go to graduate school for Molecular Biology (yay!.pdf
You have decided to go to graduate school for Molecular Biology (yay!.pdf
arshin9
 
Write a java program to randomly generate the following sets of data.pdf
Write a java program to randomly generate the following sets of data.pdfWrite a java program to randomly generate the following sets of data.pdf
Write a java program to randomly generate the following sets of data.pdf
arshin9
 
What is the between facial action unit and facial landmark differenc.pdf
What is the between facial action unit and facial landmark differenc.pdfWhat is the between facial action unit and facial landmark differenc.pdf
What is the between facial action unit and facial landmark differenc.pdf
arshin9
 
Significance of Discoveries in Genetics and DNA Our understandin.pdf
Significance of Discoveries in Genetics and DNA Our understandin.pdfSignificance of Discoveries in Genetics and DNA Our understandin.pdf
Significance of Discoveries in Genetics and DNA Our understandin.pdf
arshin9
 

More from arshin9 (20)

Bats rely on sound localization to be able to fly during the night. O.pdf
Bats rely on sound localization to be able to fly during the night. O.pdfBats rely on sound localization to be able to fly during the night. O.pdf
Bats rely on sound localization to be able to fly during the night. O.pdf
 
A layer of dirt must be spread over a circular area 13.5 feet in dia.pdf
A layer of dirt must be spread over a circular area 13.5 feet in dia.pdfA layer of dirt must be spread over a circular area 13.5 feet in dia.pdf
A layer of dirt must be spread over a circular area 13.5 feet in dia.pdf
 
Discuss the impact that the tonnage of sulfur or sulfuric acid recov.pdf
Discuss the impact that the tonnage of sulfur or sulfuric acid recov.pdfDiscuss the impact that the tonnage of sulfur or sulfuric acid recov.pdf
Discuss the impact that the tonnage of sulfur or sulfuric acid recov.pdf
 
You have decided to go to graduate school for Molecular Biology (yay!.pdf
You have decided to go to graduate school for Molecular Biology (yay!.pdfYou have decided to go to graduate school for Molecular Biology (yay!.pdf
You have decided to go to graduate school for Molecular Biology (yay!.pdf
 
write the HTML to associate a web page with an external style sheet .pdf
write the HTML to associate a web page with an external style sheet .pdfwrite the HTML to associate a web page with an external style sheet .pdf
write the HTML to associate a web page with an external style sheet .pdf
 
Why was any carbon-containing molecule originally called organic.pdf
Why was any carbon-containing molecule originally called organic.pdfWhy was any carbon-containing molecule originally called organic.pdf
Why was any carbon-containing molecule originally called organic.pdf
 
Which of the following is true about indexes and index design a. in.pdf
Which of the following is true about indexes and index design  a. in.pdfWhich of the following is true about indexes and index design  a. in.pdf
Which of the following is true about indexes and index design a. in.pdf
 
Write a java program to randomly generate the following sets of data.pdf
Write a java program to randomly generate the following sets of data.pdfWrite a java program to randomly generate the following sets of data.pdf
Write a java program to randomly generate the following sets of data.pdf
 
What kind of organisms likely perished due to the increase of oxygen .pdf
What kind of organisms likely perished due to the increase of oxygen .pdfWhat kind of organisms likely perished due to the increase of oxygen .pdf
What kind of organisms likely perished due to the increase of oxygen .pdf
 
what is the HTTP protocol used for What are its major parts.pdf
what is the HTTP protocol used for What are its major parts.pdfwhat is the HTTP protocol used for What are its major parts.pdf
what is the HTTP protocol used for What are its major parts.pdf
 
What is the between facial action unit and facial landmark differenc.pdf
What is the between facial action unit and facial landmark differenc.pdfWhat is the between facial action unit and facial landmark differenc.pdf
What is the between facial action unit and facial landmark differenc.pdf
 
What are contemporary management challenges and opportunitiesSo.pdf
What are contemporary management challenges and opportunitiesSo.pdfWhat are contemporary management challenges and opportunitiesSo.pdf
What are contemporary management challenges and opportunitiesSo.pdf
 
Valinomycin is a potassium ionophore. What would be its effect on in.pdf
Valinomycin is a potassium ionophore. What would be its effect on in.pdfValinomycin is a potassium ionophore. What would be its effect on in.pdf
Valinomycin is a potassium ionophore. What would be its effect on in.pdf
 
The retrovirus genome is made of the nucleic acid before the virus be.pdf
The retrovirus genome is made of the nucleic acid before the virus be.pdfThe retrovirus genome is made of the nucleic acid before the virus be.pdf
The retrovirus genome is made of the nucleic acid before the virus be.pdf
 
the probability that it is raining is .25. the orbability that it is.pdf
the probability that it is raining is .25. the orbability that it is.pdfthe probability that it is raining is .25. the orbability that it is.pdf
the probability that it is raining is .25. the orbability that it is.pdf
 
2)In presentation software, you can use a(n) ____ to add movement to.pdf
2)In presentation software, you can use a(n) ____ to add movement to.pdf2)In presentation software, you can use a(n) ____ to add movement to.pdf
2)In presentation software, you can use a(n) ____ to add movement to.pdf
 
Significance of Discoveries in Genetics and DNA Our understandin.pdf
Significance of Discoveries in Genetics and DNA Our understandin.pdfSignificance of Discoveries in Genetics and DNA Our understandin.pdf
Significance of Discoveries in Genetics and DNA Our understandin.pdf
 
Scope is much less complicated if functions cannot contain other func.pdf
Scope is much less complicated if functions cannot contain other func.pdfScope is much less complicated if functions cannot contain other func.pdf
Scope is much less complicated if functions cannot contain other func.pdf
 
Refer to the drawings in Figure 13.2 of a single pair of homologous c.pdf
Refer to the drawings in Figure 13.2 of a single pair of homologous c.pdfRefer to the drawings in Figure 13.2 of a single pair of homologous c.pdf
Refer to the drawings in Figure 13.2 of a single pair of homologous c.pdf
 
Prions are viruses that cause proteins to misfold. Select one True.pdf
Prions are viruses that cause proteins to misfold.  Select one  True.pdfPrions are viruses that cause proteins to misfold.  Select one  True.pdf
Prions are viruses that cause proteins to misfold. Select one True.pdf
 

Recently uploaded

SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MysoreMuleSoftMeetup
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
EADTU
 

Recently uploaded (20)

How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 

Introduction Programmers for a Better TomorrowProgrammers for a B.pdf

  • 1. 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:
  • 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. Sample Data Items You may wish to use these data structures to help you solve the problem. int status[2][5]; char TYPES[5][20] = {“PROTEIN”, “DAIRY”, “GRAINS”, “VEGETABLES”, “FRUITS”}; The values in “TYPES” are strings and may be printed with %s. For example, to print “DAIRY” we could use printf(“%s”, TYPES[1]); Input Specification All inputs will be greater than or equal to zero Output Specification View the sample run to see how the output tables should be formatted. Output Sample Below is a sample output of running the program. Note that this sample is NOT a comprehensive test. You should test your program with different data than is shown here based on the specifications given above.
  • 3. In the sample run below, for clarity and ease of reading, the user input is given in italics while the program output is in bold. (Note: When you actually run your program no bold or italics should appear at all. These are simply used in this description for clarity’s sake.) Sample Run 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
  • 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 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
  • 5. 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
  • 6. 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
  • 7. 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! Solution /** C program that prints a menu to choose type of choice and type of food that to donate or request or fullfill or print status. */ //foodbank.c #include #include #include //global variables int status[2][5]; char TYPES[5][20] = {"PROTEIN", "DAIRY", "GRAINS", "VEGETABLES", "FRUITS"}; //function prototypes int menu();
  • 8. int type(); void printStatus(); //main funtion int main() { bool repeat=true; int donation=0; int request=0; int donationType=0; while(repeat) { int ch=menu(); switch(ch) { case 1: donationType=type(); printf(" How many would you like to enter? "); scanf("%d",&donation); status[ch-1][donationType]+=donation; printf(" Donation Added. "); break; case 2: donationType=type(); printf(" What would you like to request? "); scanf("%d",&request); status[ch-1][donationType]+=request; printf(" Donation Added. "); break; case 3: for(int index=0;index<5;index++) { if(status[0][index]>=status[1][index]) { status[0][index]=status[0][index]-status[1][index];
  • 9. status[1][index]=0; } else if(status[0][index]!=0 && status[1][index]>0) { status[1][index]=status[1][index]-status[0][index]; status[0][index]=0; printf("%s requests will be partially fulfilled. ",TYPES[index]); } else printf("%s requests cannot be fulfilled. ", TYPES[index]); } break; case 4: printStatus(); break; case 5: getch(); printf(" Thank you for running our system!"); exit(0); } } getch(); return 0; } //print status of food bank void printStatus() { int i; for(i=0;i<5;i++) { printf("%-15s Donations: %d Request: %d ", TYPES[i],status[0][i],status[1][i]); }
  • 10. } //function that prompt for type of choice from user int menu() { int choice; do { printf("Welcome to the Food Bank Management Program! "); printf("What would you like to do? "); printf("t1. Enter a Donation "); printf("t2. Enter a Request "); printf("t3. Fulfill Requests "); printf("t4. Print status report "); printf("t5. Exit "); scanf("%d",&choice); }while(choice <1 || choice>5); return choice; } //function that prompts user to select the type of food int type() { int donationType; do { printf(" What donation type would you like to enter? "); printf("t0. Protein "); printf("t1. Dairy "); printf("t2. Grains "); printf("t3. Vegetables "); printf("t4. Fruits "); scanf("%d",&donationType); }while(donationType<0 || donationType>4); return donationType; } ------------------------------------------
  • 11. Sample 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. 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 2 How many would you like to enter? 10 Donation Added. Welcome to the Food Bank Management Program!
  • 12. 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 Request: 0 DAIRY Donations: 0 Request: 0 GRAINS Donations: 10 Request: 0 VEGETABLES Donations: 0 Request: 0 FRUITS Donations: 0 Request: 0 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 4 PROTEIN Donations: 5 Request: 0 DAIRY Donations: 0 Request: 0 GRAINS Donations: 10 Request: 0 VEGETABLES Donations: 0 Request: 0 FRUITS Donations: 0 Request: 0 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