(Solved) : Instructions Inputtxt File Output Far Need Help Writing Main Function C Include Include In Q37170432 . . .
Instructions:

Input.txt file:

Output:

What I have so far: (I need help with writing the main functionin c)
#include
#include
#include
#define LENGTH 80
#define TRUE
struct produceItem
{
char produce[20];
char type[20];
char soldBy[20];
float price;
int quantityInStock;
struct produceItem *next;
};
// function prototypes
void addProduceItem(struct produceItem **, char *, char *, char *,float, int);
void count();
void display(struct produceItem *);
void readDataFile(struct produceItem **);
void recursiveReverse(struct produceItem **);
char * trim(char *c);
void writeDataFile(struct produceItem *);
void addProduceItem (struct produceItem **headRef, char *produce,char *type, char *soldBy, float price, int quantity)
{
struct produceItem* temp = (struct produceItem *)malloc(sizeof(struct produceItem));
strcpy(temp->produce,produce);
strcpy(temp->type, type);
strcpy(temp->soldBy, soldBy);
temp->price = price;
temp ->quantityInStock = quantity;
temp->next = (*headRef);
(*headRef) = temp;
}
void display(struct produceItem *headRef)
{
struct produceItem *helper = headRef;
if (helper ==NULL)
{
return;
}
else
{
printf(“=======================================================n”);
printf(” Item # Produce Type Sold By Price In Stockn”);
printf(“=======================================================n”);
}
int counter = 1;
while(helper !=NULL)
{
printf(“%5d %3s %-13s %-16s %-13s %6.2f %8d n”,
counter++, ” “, helper->produce, helper->type,
helper->soldBy, helper->price,helper->quantityInStock);
helper = helper->next;
}
printf(“n”);
}
void readDataFile(struct produceItem **headRef)
{
const char comma[2] = “,”;
char dataLine[LENGTH];
char *produce;
char *type;
char *soldBy;
float price;
int quantityInStock;
char *fileName = “Assignment8Input.txt”;
FILE *filePointer;
printf(“Trying to open file %sn”, fileName);
filePointer = fopen(fileName, “r”); // read mode
// }
// else
// {
// printf(“Successfully opened file %sn”, fileName);
//
// }
// }
// else
// {
// printf(“Successfully opened file %sn”, fileName);
//
// }
while (fgets(dataLine, LENGTH, filePointer) !=NULL)
{
produce = trim(strtok(dataLine, “,”));
type = trim(strtok(NULL, “,”));
soldBy = trim(strtok(NULL,”,”));
price = atof(trim(strtok(NULL,”,”)));
quantityInStock = atoi (trim(strtok(NULL,”,”)));
addProduceItem(headRef, produce, type, soldBy, price,quantityInStock);
}
fclose(filePointer);
}
void recursiveReverse(struct produceItem** head_ref)
{
struct produceItem* first;
struct produceItem* rest;
}
char * trim(char *c)
{
char * e = c + strlen(c) – 1;
while(*c && isspace(*c))
c++;
while(e > c && isspace(*e))
*e– = ”;
return c;
}
int printMenu()
{
int option;
printf(“List Operations n”);
printf(“===============n”);
printf(“1. Stack Produce Departmentn”);
printf(“2. Display Produce Inventory ~ Stackn”);
printf(“3. Display Produce Inventory ~ Queuen”);
printf(“4. Pop 10 Elements Off Stack and Outputn”);
printf(“5. Dequeue 15 Elements Off Queue and Outputn”);
printf(“6. Exit Programn”);
printf(“Enter your choice: “);
scanf(“%d”,&option);
return option;
}
int main()
{
int option = printMenu();
while (option!=6)
{
if(option==1)
{
//call the function that will Stack produce department
}
if(option==2)
{
//call the function that will Display Produce Inventory ~Stack
}
if(option==3)
{
//call the function that will Display Produce Inventory ~Queue
}
if(option==4)
{
//call the function that will Pop 10 Elements Off Stack andOutput
}
if(option==5)
{
//call the function that will Dequeue 15 Elements Off Queue andOutput
}
option = printMenu();
}
return 0;
}
Taks and Rubrk Perforei the CLOBAL HEAD, TOP rovide the use ame of the folloinz pos all fnction to read in the dats file Expeeted autcoaie 1. Stock Produce Drtment alltunton to dspay h dattsotigure all function to aspay the dathe feat shoo iiure 4. Pog o file As 10 elements or stack rmting each eement to opt Figare 2 Afner Oplian2 fuction to pap TL0 clenucnta aund wane cach netta cu ile eaconditicnal tement to ute the er’s election to reod de t dur Function to dapiy e the queue the dora od eac peue ts od the stazk und wine each elemert to pap and cupet Fgure 1 Appicadon Start opat file Zucchini, Squash, pound, 2.19, 45 Yellow, Squash, pound, 1.79, 15 Tomatoes, Ugly Ripe, each, .99, 67 Strawberries, , package, 4.99, 38 Spaghetti, Squash, each, 1.99, 18 Raspberries, Red, package, 3.99, 50 Radishes, Red, package, .99, 25 Peppers, Jalapeno, pouna, . 99 Peppers, Green, each, .59, 100 Orange,Navel, pound, 1.99, 80 Okra, , package, 6.99, 12 Mushrooms, Shiitake, package, 4.99, 20 Mango, , each, 3.59, 44 Lime, Persian, each, .10, 60 Lettuce, Iceberg, each, 1.19, 100 Lemon, , each, 29, 40 Kiwi, , each, .99, 20 Green Beans, stringless, pound, 1.59, 80 Grapes, Red Seedless, pound, 1.99, 8 Eggplant, Japanese, each, 1.59, 10 Cauliflower, , each, 2.59, 26 Cantaloupe Broccoli, Florets, package, 3.45, 67 Blueberries, ,package, 3.99, 43 Asparagus pouna, 2-54, 23 Apple, Granny Smith, pound, 2.99, 100 , , each, 1.49, 53 Item # Produce Sold By In Stock Type Price 2.99 2.54 100 Granny Smith pound pound package package each each each pound pound each Asparagus Blueberries Broccoli Cantaloupe Cauliflower Eggplant Grapes Green Beans Stringless Florets 2.59 Japanese Red Seedles:s 1.59 0.99 Figure 4 Assignment2Output.txt After Option 4 Item # Produce In Stock Type Sold By Price Apple Asparagus Blueberries Broccoli Cantaloupe Cauliflower Eggplant Grapes Green BeansStzingless Kiwi Granny Smith 2.99 100 pound package package each each each pound pound each 3.99 3.45 Florets 2.59 7 Japanese Red Seedless 1.99 0.99 Item# Produce Type Sold By Price In Stock each 0.29 each 0.99 Green Beans Stingless Grapes Egcplant Cauliflower Cantaloupe Broccoli Blueberries Asparagus Apple Red Seedless Japanese 1.99 each each each package package 1.49 3.45 3.99 FloretS Granny Smith 2.99 100 Figure 5 Assignment2.txt After Option 5 Show transcribed image text Taks and Rubrk Perforei the CLOBAL HEAD, TOP rovide the use ame of the folloinz pos all fnction to read in the dats file Expeeted autcoaie 1. Stock Produce Drtment alltunton to dspay h dattsotigure all function to aspay the dathe feat shoo iiure 4. Pog o file As 10 elements or stack rmting each eement to opt Figare 2 Afner Oplian2 fuction to pap TL0 clenucnta aund wane cach netta cu ile eaconditicnal tement to ute the er’s election to reod de t dur Function to dapiy e the queue the dora od eac peue ts od the stazk und wine each elemert to pap and cupet Fgure 1 Appicadon Start opat file
Zucchini, Squash, pound, 2.19, 45 Yellow, Squash, pound, 1.79, 15 Tomatoes, Ugly Ripe, each, .99, 67 Strawberries, , package, 4.99, 38 Spaghetti, Squash, each, 1.99, 18 Raspberries, Red, package, 3.99, 50 Radishes, Red, package, .99, 25 Peppers, Jalapeno, pouna, . 99 Peppers, Green, each, .59, 100 Orange,Navel, pound, 1.99, 80 Okra, , package, 6.99, 12 Mushrooms, Shiitake, package, 4.99, 20 Mango, , each, 3.59, 44 Lime, Persian, each, .10, 60 Lettuce, Iceberg, each, 1.19, 100 Lemon, , each, 29, 40 Kiwi, , each, .99, 20 Green Beans, stringless, pound, 1.59, 80 Grapes, Red Seedless, pound, 1.99, 8 Eggplant, Japanese, each, 1.59, 10 Cauliflower, , each, 2.59, 26 Cantaloupe Broccoli, Florets, package, 3.45, 67 Blueberries, ,package, 3.99, 43 Asparagus pouna, 2-54, 23 Apple, Granny Smith, pound, 2.99, 100 , , each, 1.49, 53
Item # Produce Sold By In Stock Type Price 2.99 2.54 100 Granny Smith pound pound package package each each each pound pound each Asparagus Blueberries Broccoli Cantaloupe Cauliflower Eggplant Grapes Green Beans Stringless Florets 2.59 Japanese Red Seedles:s 1.59 0.99 Figure 4 Assignment2Output.txt After Option 4 Item # Produce In Stock Type Sold By Price Apple Asparagus Blueberries Broccoli Cantaloupe Cauliflower Eggplant Grapes Green BeansStzingless Kiwi Granny Smith 2.99 100 pound package package each each each pound pound each 3.99 3.45 Florets 2.59 7 Japanese Red Seedless 1.99 0.99 Item# Produce Type Sold By Price In Stock each 0.29 each 0.99 Green Beans Stingless Grapes Egcplant Cauliflower Cantaloupe Broccoli Blueberries Asparagus Apple Red Seedless Japanese 1.99 each each each package package 1.49 3.45 3.99 FloretS Granny Smith 2.99 100 Figure 5 Assignment2.txt After Option 5
Expert Answer
Answer to Instructions: Input.txt file: Output: What I have so far: (I need help with writing the main function in c) #include #in…
OR