Question: Hello I need help with this problem solving it in C. I have a sample code bellow labelled 'yellowbox' and I need the code that

Hello I need help with this problem solving it in C. I have a sample code bellow labelled 'yellowbox' and I need the code that would be put in " /*ADD YOUR CODE HERE*/ ". I do not need advice on how to solve the problem, I just want the solution. THANK YOU!

Hello I need help with this problem solving it in C. Ihave a sample code bellow labelled 'yellowbox' and I need the codethat would be put in " /*ADD YOUR CODE HERE*/ ". Ido not need advice on how to solve the problem, I justwant the solution. THANK YOU! YELLOWBOX SAMPLE CODE: #include #include /* The

YELLOWBOX SAMPLE CODE:

#include #include

/* The following constant definitions may be helpful */ #define MAX_MOVIE_TITLES 50 /* Max # of unique titles this kiosk can hold */ #define MAX_TITLE_LENGTH 50 /* Max chars in a movie title, not counting \0 */ #define MAX_DISC_CAPACITY 50 /* How many DVDs can this machine hold in all? */

void trim(char * string) { /* Remove any trailing spaces from a string */ char * temp = string;

/* move to last character of string */ while (*temp != '\0') { temp++; }

temp--; /* move to very last non-NULL character */

while (*temp == ' ' && temp != string) { *temp = '\0'; /* replace trailing spaces with terminator */ temp--; } }

/* Add your code here */

int findMovie (char * title) { return -1; /* CHANGE OR MODIFY THIS LINE */ }

int addMovie (char * title) { return 0; /* CHANGE OR MODIFY THIS LINE */ }

int rentMovie (char * title) { return 0; /* CHANGE OR MODIFY THIS LINE */ }

void printInventory () { }

int addStock (char * filename) { return 0; /* CHANGE OR MODIFY THIS LINE */ }

int processTransactions (char * transactionFile) { return 0; /* CHANGE OR MODIFY THIS LINE */ }

int main(void) { printInventory();

char stockFile[100]; printf("Enter the name of the initial stock file: "); scanf("%s", stockFile); int status = addStock(stockFile);

if (status != 0) { printInventory();

char transFile[100]; printf("Enter the name of the transaction file: "); scanf("%s", transFile); int successes = processTransactions(transFile);

if (successes > 0) { printf("Performed %d successful transaction(s). ", successes);

printInventory(); } else { printf("Unable to complete any transactions successfully... "); } } else { printf("ERROR: Unable to initialize kiosk! "); }

return 0; }

Project Description Redbox is a nationwide network of kiosks where customers can rent DVDs, Blu-Ray discs, and video games. For this project, we will implement a program named "YellowBox that emulates a Redbox kiosk (to a very limited degree) using arrays, structures, and file l/O. We have given you a skeleton source code file named "yellowbox.c"; you may use this as a starting point for your project (for example, a fully-working main() function is already provided for you), or re- implement everything on your own Follow the steps below to complete the project assignment. Two sample data files have been provided on Blackboard for you to use while testing your code 1. Start by defining some useful data types and global variables 1. Define a struct to represent a particular movie. A movie struct contains a string that holds the movie's title, and an integer that tracks the number of copies that are currently in stock. For example, a variable of this type might record that the kiosk currently contains 3 copies of "Braveheart" 2. Create a array to hold your movie structures. You may assume that our kiosk will track no more than 50 distinct movie titles 3. Create a global integer variable to track the total number of distinct movie titles that the kiosk knows about (i.e., has seen at some point through a transaction request). This variable's value also indicates the total number of occupied positions in your movie array. Initialize this variable to 0 4. Create a global integer variable to track the total number of discs that are currently held in the kiosk. Initialize this variable to 0 2. Complete the findMovie helper function, which locates a particular movie title in your array int findMovie (char *title) If the kiosk is currently empty, this function returns -1 Otherwise, use a loop to examine each movie structure in your array of movies. If the current movie's title matches the title you are searching for (use the strcmp function compare two strings), return the index of the matching movie structure from your array. you complete the loop without finding a match, return -1 to indicate that the title is not present Project Description Redbox is a nationwide network of kiosks where customers can rent DVDs, Blu-Ray discs, and video games. For this project, we will implement a program named "YellowBox that emulates a Redbox kiosk (to a very limited degree) using arrays, structures, and file l/O. We have given you a skeleton source code file named "yellowbox.c"; you may use this as a starting point for your project (for example, a fully-working main() function is already provided for you), or re- implement everything on your own Follow the steps below to complete the project assignment. Two sample data files have been provided on Blackboard for you to use while testing your code 1. Start by defining some useful data types and global variables 1. Define a struct to represent a particular movie. A movie struct contains a string that holds the movie's title, and an integer that tracks the number of copies that are currently in stock. For example, a variable of this type might record that the kiosk currently contains 3 copies of "Braveheart" 2. Create a array to hold your movie structures. You may assume that our kiosk will track no more than 50 distinct movie titles 3. Create a global integer variable to track the total number of distinct movie titles that the kiosk knows about (i.e., has seen at some point through a transaction request). This variable's value also indicates the total number of occupied positions in your movie array. Initialize this variable to 0 4. Create a global integer variable to track the total number of discs that are currently held in the kiosk. Initialize this variable to 0 2. Complete the findMovie helper function, which locates a particular movie title in your array int findMovie (char *title) If the kiosk is currently empty, this function returns -1 Otherwise, use a loop to examine each movie structure in your array of movies. If the current movie's title matches the title you are searching for (use the strcmp function compare two strings), return the index of the matching movie structure from your array. you complete the loop without finding a match, return -1 to indicate that the title is not present

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!