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

A Fastfood store manager wants you to create a program to keep track of all of h

ID: 3751649 • Letter: A

Question

A Fastfood store manager wants you to create a program to keep track of all of his inventory and workers. You are given 4 files: Food.txt, Employee.txt, Condiment.txt, and PlasticItem.txt. Create an array of structs for each file to hold the entries.

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)

Condiment.txt

1. Name

2. Ounces Remaining

3. Expiration Date (month:day:year)

4. Cost

PlasticItem.txt

1. Name

2. Number Remaining

3. Cost

Write a C++ program to help the Fast Food store owner. Create four arrays of structs named Food, Employee, Condiment, and PlasticItem. The size of the array should be read in from the file. 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 PlasticItem). Do NOT use global variables.

In the first line of each file there will be a number indicating how many entries are in the file.

Food.txt

Condiments.txt

Employee.txt

PlasticItem.txt

Sample Output:

ZARestaurant bin DebugRestaurant.exe This is Assignment 1 (Structs estaurant Select which option you would like to see . Print all Food 2. Print all Employees 3. Print al1 Condiments 4. Print all Plastic Items 5. Exit Enter Option 1-5 ZARestaurantibinDebuglRestaurant.exe Food Nane Nunber left Sell By Date Cost Tonato Cucumber Bread Eggs Turkey Orange Lettuce HotDog Chicken Bun Burger Rib Apple Banana Carrot 20 89 07:02:2015 06:15:2014 06:25:2017 08:29:2015 05:1:2010 04:19:2011 09:05:2002 05:20:2010 03:11:2016 06:24:2013 03:29:2016 06:15:2013 08:21:2012 10:22:2013 09:22:2013 1.95 0.89 2.69 2.33 1.72 0.12 0.3 0.99 1.01 1.89 66.6 1.23 1.87 1.95 1.99 56 16 40 16 18 21

Explanation / Answer

#include<iostream.h>

#include<conio.h>

#include<bits/stdc++.h>

#include<string.h>

#include<fstream.h>

struct food{

char name[20];

int numrem;

char expdate[10];

float cost;

} //Structure for food

struct employee{

char name[20];

int id;

float salary;

char hiredate[10];

int rating;

} //Structure for employee

struct condiment{

char name[20];

float ounce_rem;

char expdate[10];

float cost;

} //Structure for condiment

struct plasticitem{

char name[20];

int numrem;

float cost;

} //Structure for plasticitem

int main(){

int size1,size2,size3,size4,i=0; //4 sizes for all 4 structures, i for looping

char data[100]; // Data[100] to read data from the file

clrscr();

ifstream infile; //creating object infile

infile.open("Food.txt",ios::in); //opening in reading mode

infile>>size1; //storing size number of entries in this file

struct food foodinfo[size1]; // Declaring food structure array of size1 size

while(infile){

infile>>data; //reading name

foodinfo[i].name=data; //storing name

infile>>data; // reading number remaining

foodinfo[i].numrem=stoi(data); //converting and storing in numrem

infile>>data; // reading expire date

foodinfo[i].expdate=data; //storing expire date in expdate

infile>>data; //reading cost

foodinfo[i].cost=strtof((data).c_str(),0); //converting and storing cost

i++;

}

infile.close(); //closing file

// Similarly remaining 3 are read

i=0;

ifstream infile;

infile.open("Employee.txt",ios::in);

infile>>size2;

struct employee empinfo[size2];

while(infile){

infile>>data;

empinfo[i].name=data;

infile>>data;

empinfo[i].id=stoi(data);

infile>>data;

empinfo[i].salary=strtof((data).c_str(),0);

infile>>data;

empinfo[i].hiredate=data;

infile>>data;

empinfo[i].rating=stoi(data);

i++;

}

infile.close();

i=0;

ifstream infile;

infile.open("Condiment.txt",ios::in);

infile>>size3;

struct condiment coninfo[size3];

while(infile){

infile>>data;

coninfo[i].name=data;

infile>>data;

coninfo[i].ounce_rem=strtof((data).c_str(),0);

infile>>data;

coninfo[i].expdate=data;

infile>>data;

coninfo[i].cost=strtof((data).c_str(),0);

i++;

}

infile.close();

i=0;

ifstream infile;

infile.open("PlasticItem.txt",ios::in);

infile>>size4;

struct plasticitem plasinfo[size4];

while(infile){

infile>>data;

plasinfo[i].name=data;

infile>>data;

plasinfo[i].numrem=stoi(data);

infile>>data;

plasinfo[i].cost=strtof((data).c_str(),0);

i++;

}

infile.close();

getch();

return 0;

}

//use this only in C11 or C14

//Also this may not run due to compiler issues so try replacing some syntax according to your compiler

This is only for reading not for getting output.

You can use this code to get output.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote