Question: REFERENCED CODE TO MODIFY: MAIN.CPP: #include #include #include using namespace std; struct Date{ int day; int month; int year; }; struct Food{ string name; int


REFERENCED CODE TO MODIFY:
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
Obiectives: The main objective of this assignment is checking students' ability to implement membership functions. After completing this assignment, students will be able to: implement member functions convert a member function into a standalone function convert a standalone function into a member function call member functions implement constructors use structs for function overloadingg
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
