Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Obiestives: The major advantage of using structs is to make the C++ code simpler

ID: 3752142 • Letter: O

Question

Obiestives: 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, stadents will be able to . usestructs to create andlor introduce new custom data types implement structs to group fixed numbers of pieces of data of different types implement structs within struets e chaining using the dot operatoes to access nested fields · copy an entire structure . create an array of a structured data type * combine structs and arrays with one another to ereate 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 Plastichem.txt t array of structs for cach file to hold the entries. The first line of cach file will be a number indicating how mamy entries Food.ixi are in the file I. Name 2. Number Remaining Expiration Date (month day year) Cost I. Name 2. Id 3. Salary Hire Date (movenk day year) . Rating (1-10) 1. Name 2. Ounces Remaining Expiration Date (month day year 4. Cost 1. Name 2. Number Remaining 3. Cost Write a C++ program to help the restaurant owner. Create four arrays of structs named Food, Emploer Condiment, and Plasticltem. The size of the array should be read in from the fik. Structs should be created to hold the variables that won't fit a standard data type The main function of your program should be very simple. The main function should be a collection of variable declarations and function calls. You will need to use four different functions to read the data from the four files. You can add more functions if you want. You are to give the user the ability to print out each section's records (Food, Employee, Condiment, and Plasticltem) Do NOT use global variables If you do so there will be a dedaction of 10 points from your total points. Please check the attachod "Grading Rubric" for the grading eriteria

Explanation / Answer

The below program read the data from the text file . We need to mention the file location path, if the file is saved in differenet drive.

#include <iostream>
#include <fstream>
#include <iostream>
using namespace std;
struct Food{
char Name[50];
int number remaining;
int Expiration date;
int cost;
void dispdata(){
ifstream f;
f.open("Food.txt");
while(!f.eof()){
f>>name;
cout << name;
f>> number remaining;
cout << number remaining;
f >> Expiration date;
cout << expiration date;
f>> cost;
cout << cost;
}
}
}
struct Employees{
char Name[50];
int Id;
float salary;
int Hire date;
int Rating;
}
void Disp1(){
ifstream f;
f.open("Food.txt");
while(!f.eof()){
f >>name;
cout << name;
f >> Id;
cout << Id;
f >> Salary;
cout << salary;
f >> Hire date;
cout << Hire date;
Employees >> Rating;
cout<< Rating;
}

}
struct Condiments{
char name[50];
int Ounces Remaining;
int Expiration Date;
int Cost;
}
void Disp2(){
ifstream f;
f.open("Condiments.txt");
while(!Condiments.eof()){
f >>name;
cout << name;
f >> Ounces Remaining;
cout << Ounces remaining;
f >> Expiration date;
cout << expiration date;
f >> cost;
cout << cost;
}
}
}
struct Plastic items{
char name[50];
int Number Remaining;
int Cost;
}
void Disp3(){
ifstream f;
f.open("Plastic items.txt");
while(!f.eof()){
f >>name;
cout << name;
f >> Number Remaining;
cout << Number remaining;
f >> cost;
cout << cost;
}
}



int main () {
int n;
cout << "Select which option you would like to see";
cout << "1. Print all Food";
cout << "2. Print all Employees";
cout << "3. Print all Condiments";
cout<< "4. Print all Plastic Items";
cout << "5. Exit";
  
switch(n){
case 1: {


void Dispdata()

}
case 2:


void Disp1();


}
case 3: {


  
Void Disp2();

}
case 4: {



void Disp3();


}
case 5:{
Exit();
}
}

#include <iostream>
#include <fstream>
#include <iostream>
using namespace std;
struct Food{
char Name[50];
int number remaining;
int Expiration date;
int cost;
void dispdata(){
ifstream f;
f.open("Food.txt");
while(!f.eof()){
f>>name;
cout << name;
f>> number remaining;
cout << number remaining;
f >> Expiration date;
cout << expiration date;
f>> cost;
cout << cost;
}
}
}
struct Employees{
char Name[50];
int Id;
float salary;
int Hire date;
int Rating;
}
void Disp1(){
ifstream f;
f.open("Food.txt");
while(!f.eof()){
f >>name;
cout << name;
f >> Id;
cout << Id;
f >> Salary;
cout << salary;
f >> Hire date;
cout << Hire date;
Employees >> Rating;
cout<< Rating;
}

}
struct Condiments{
char name[50];
int Ounces Remaining;
int Expiration Date;
int Cost;
}
void Disp2(){
ifstream f;
f.open("Condiments.txt");
while(!Condiments.eof()){
f >>name;
cout << name;
f >> Ounces Remaining;
cout << Ounces remaining;
f >> Expiration date;
cout << expiration date;
f >> cost;
cout << cost;
}
}
}
struct Plastic items{
char name[50];
int Number Remaining;
int Cost;
}
void Disp3(){
ifstream f;
f.open("Plastic items.txt");
while(!f.eof()){
f >>name;
cout << name;
f >> Number Remaining;
cout << Number remaining;
f >> cost;
cout << cost;
}
}



int main () {
int n;
cout << "Select which option you would like to see";
cout << "1. Print all Food";
cout << "2. Print all Employees";
cout << "3. Print all Condiments";
cout<< "4. Print all Plastic Items";
cout << "5. Exit";

cout << "Enter the option <1-5>:";

cin>>n;
  
switch(n){
case 1: {


void Dispdata()

}
case 2:


void Disp1();


}
case 3: {


  
Void Disp2();

}
case 4: {



void Disp3();


}
case 5:{
Exit();
}
}

getch();

}