Question: main.cpp #include #include #include using namespace std; struct Date{ int day; int month; int year; }; struct Food{ string name; int numberLeft; Date sellByDate; double

 main.cpp #include #include #include using namespace std; struct Date{ int day;int month; int year; }; struct Food{ string name; int numberLeft; Date

main.cpp

 #include  #include  #include  using namespace std; struct Date{ int day; int month; int year; }; struct Food{ string name; int numberLeft; Date sellByDate; double cost; }; struct Employee{ string name; int id; double salary; Date hireDate; int rating; }; struct Condiment{ string name; double ouncesLeft; Date sellByDate; double cost; }; struct PlasticItem{ string name; int numberLeft; double cost; }; /** These four functions are mandatory as instructed in the Assignment **/ void getFoodData(ifstream& inFile); void getEmployeeData(ifstream& inFile); void getCondimentData(ifstream& inFile); void getPlasticItemsData(ifstream& inFile); /** Optional Helper Functions **/ void displayFood(Food food[], int totalFood); void displayEmployees(Employee employee[], int totalEmployees); void displayCondiments(Condiment condiment[], int totalCondiments); void displayPlasticItems(PlasticItem plasticItem[], int totalPlastiicItems); void printHorizontalLine( int width, char border_char); void printHeading( string title, int width ); int main() { cout > chosenOption; /** Do the correct action according to the chosenOption **/ switch(chosenOption) { case 1: /** Food Function call to read data from input file. That function then calls a print Function **/ getFoodData(inFileFood); break; case 2: /** Employees Function call to read data from input file. That function then calls a print Function **/ getEmployeeData(inFileEmployee); break; case 3: /** Condiments Function call to read data from input file. That function then calls a print Function **/ getCondimentData(inFileCondiment); break; case 4: /** Plastic Items Function call to read data from input file. That function then calls a print Function **/ getPlasticItemsData(inFilePlasticItem); break; default: break; } }while(chosenOption != 5); return 0; } void printHorizontalLine( int width, char border_char){ cout.fill( border_char ); cout > totalFood; Food food[totalFood]; char decimal; for(int i = 0; i > food[i].name; inFile >> food[i].numberLeft; inFile >> food[i].sellByDate.month >> decimal >> food[i].sellByDate.day >> decimal >> food[i].sellByDate.year; inFile >> food[i].cost; } inFile.close(); printHeading("Food", 60); displayFood(food,totalFood); } /** Using the input stream sent as parameter we are reading the content from the condiments.txt and storing it in the condiments struct array **/ void getCondimentData(ifstream& inFile){ inFile.open("Condiment.txt"); int totalCondiments; inFile >> totalCondiments; Condiment condiments[totalCondiments]; char decimal; for(int i = 0; i > condiments[i].name; inFile >> condiments[i].ouncesLeft; inFile >> condiments[i].sellByDate.month >> decimal >> condiments[i].sellByDate.day >> decimal >> condiments[i].sellByDate.year; inFile >> condiments[i].cost; } inFile.close(); printHeading("Condiments", 60); displayCondiments(condiments,totalCondiments); } /** Using the input stream sent as parameter we are reading the content from the Employee.txt and storing it in the employees struct array **/ void getEmployeeData(ifstream& inFile){ inFile.open("Employee.txt"); int totalEmployees; inFile >> totalEmployees; Employee employees[totalEmployees]; char decimal; for(int i = 0; i > employees[i].name; inFile >> employees[i].id; inFile >> employees[i].salary; inFile >> employees[i].hireDate.month >> decimal >> employees[i].hireDate.day >> decimal >> employees[i].hireDate.year; inFile >> employees[i].rating; } inFile.close(); printHeading("Employees", 60); displayEmployees(employees,totalEmployees); } /** Using the input stream sent as parameter we are reading the content from the Personnel.txt and storing it in the plasticItem struct array **/ void getPlasticItemsData(ifstream& inFile){ inFile.open("PlasticItem.txt"); int totalPlasticItems; inFile >> totalPlasticItems; PlasticItem plasticItem[totalPlasticItems]; for(int i = 0; i > plasticItem[i].name; inFile >> plasticItem[i].numberLeft; inFile >> plasticItem[i].cost; } inFile.close(); printHeading("Plastic Items", 60); displayPlasticItems(plasticItem,totalPlasticItems); } /** Displaying the content from the food struct array on the monitor **/ void displayFood(Food food[], int totalFood){ cout  

condiment.txt

14

Ketchup 20 01:16:2000 1.00 Mustard 40 05:14:2006 4.20 Relish 15 10:21:2015 5.50 SoySauce 98 09:08:2011 2.70 Mayonnaise 52 06:03:2013 1.60 BBQSauce 11 11:10:2004 2.00 HotSauce 70 12:06:2014 .95 Salsa 700 06:12:2003 8.00 Wasabi 15 07:18:2006 1.00 OysterSauce 12 08:22:2007 2.60 Horseradish 200 08:23:2015 1.95 TarterSauce 90 06:25:2016 2.10 FishSauce 33 04:23:2015 3.23 BrownSauce 20 08:26:2014 2.00

Employee.txt

16 Ellis 209 32750 04:01:2010 10 Patrick 676 55549 03:10:2013 3 Tommy 257 53383 06:21:2000 3 Alfie 694 27177 06:01:2005 8 Harley 971 27040 07:06:2006 2 Jeffery 690 63713 02:26:2008 3 Bently 769 70142 02:27:2015 2 Kellen 468 10978 07:13:2012 1 Ryan 894 95825 08:17:2015 7 Alexander 633 41944 06:06:2016 1 Zak 619 9499 03:22:2015 5 Ashton 987 72388 06:13:2013 9 Mason 275 63900 04:14:2017 8 Alex 460 39871 07:23:2016 7 Emery 601 51050 03:20:2010 3 Wade 748 29487 02:28:2014 5

Food.txt

15 Tomato 20 07:02:2015 1.95 Cucumber 89 06:15:2014 .89 Bread 4 06:25:2017 2.69 Eggs 11 08:29:2015 2.33 Turkey 56 05:01:2010 1.72 Orange 16 04:19:2011 .12 Lettuce 40 09:05:2002 .30 HotDog 22 05:20:2010 .99 Chicken 9 03:11:2016 1.01 Bun 1 06:24:2013 1.89 Burger 0 03:29:2016 66.60 Rib 16 06:15:2013 1.23 Apple 18 08:21:2012 1.87 Banana 44 10:22:2013 1.95 Carrot 21 09:22:2013 1.99

PlasticItem.txt

10 Forks 1000 .20 Spoons 215 .65 TrashBags 15 1.60 Napkins 5000 .20 Cups 60 .95 Plates 101 1.26 Bowls 15 2.10 Vincent 96 .55 Straws 180 1.05 Containers 280 1.32

Objectives: The major advantage of using structs is to make the C++ code simpler, easier to read, and easier to work with. After completing this assignment, students will be able to use structs to create and/or introduce new custom data types implement structs to group fixed numbers of pieces of data of different types implement structs within structs chaining using the dot operators to access nested fields copv an entire structure create an array of a structured data type combine structs and arrays with one another Task Description: A Restaurant owner wants you to create a program to keep track of all of his inven- tory and workers. You are given 4 files: Food.txt, Employee.txt, Condiment.txt, and Plasticltem.txt. Your task is to create an array of structs for each file to hold the entries. The first line of each file will be a number indicating how many entries are in the file Food.txt 1. Name 2. Number Remaining 3. Expiration Date (month:day:year) 4. Cost Employee.txt 1. Name 2. Id 3. Salary 4. Hire Date (month:day.year) 5. Rating (1-10) Objectives: The major advantage of using structs is to make the C++ code simpler, easier to read, and easier to work with. After completing this assignment, students will be able to use structs to create and/or introduce new custom data types implement structs to group fixed numbers of pieces of data of different types implement structs within structs chaining using the dot operators to access nested fields copv an entire structure create an array of a structured data type combine structs and arrays with one another Task Description: A Restaurant owner wants you to create a program to keep track of all of his inven- tory and workers. You are given 4 files: Food.txt, Employee.txt, Condiment.txt, and Plasticltem.txt. Your task is to create an array of structs for each file to hold the entries. The first line of each file will be a number indicating how many entries are in the file Food.txt 1. Name 2. Number Remaining 3. Expiration Date (month:day:year) 4. Cost Employee.txt 1. Name 2. Id 3. Salary 4. Hire Date (month:day.year) 5. Rating (1-10)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!