Question: its a C++ question, I inserted the txt attachment picture with the question... please dont forget to include comments on calculations and variables. Description In

 its a C++ question, I inserted the txt attachment picture withthe question... please dont forget to include comments on calculations and variables.

Description In this program, you will write a program to emulate a

vending machine (somewhat). The data structures used will a set of arrays

that will store data in parallel. In other words, you will have

its a C++ question, I inserted the txt attachment picture with the question... please dont forget to include comments on calculations and variables.

Description In this program, you will write a program to emulate a vending machine (somewhat). The data structures used will a set of arrays that will store data in parallel. In other words, you will have a set of arrays string snackName [MAX_ITEMS]; string itemCode [MAX_ITEMS]; int amountLeft [MAXITEMS]; double itemPrice [MAX_ITEMS] Where MAX_ITEMS will be a constant of type int and wl hold the value of 20. The vending machine will not necessary hold 20 different items, but the max is 20, and you will need a counter to keep track of the number of different items in the vending machine. We have a set of arrays that hold data in parallel, which means that snackName [0] contains the name of an item in the vending machine, and amountLeft [0] contains the amount left of item 0, so we can union all the data together by accessing the arrays and use the same index. You will read the data from a provided input file of arbitrary number of lines, each line of the input will consist of ItemName itemCode amount price and each item will be separated by a space and each line is separated by and end of file character, so you will need to read the data from a file using an end of file controlled while loop, and you need to maintain a counter after each line read to know the amount of items stored in the vending machine. Then your program will output to the user all the contents in the machine and the user will have the option to choose an item by entering an item code (you will just read a string), then the amountLeft of the element will be decremented by 1, then the program will output all the contents again to the screen (any item that has at at least 1 for its amountLeft value), of course this will also be a menu driven program that will loop until the user enters N to quit or until the vending machine becomes empty (for all i amountLeft [i] -- 0). You will need to write the following functions int readItems (ifstream& infile, string snackName [], int amountLeft C] string itemCode , double itemPrice C) will read all the contents from the file, and it will keep track of the number of lines read and populate all the arrays, then it will return an integer that represents the number of items stored in the vending machine . string format(string str) - takes in a string parameter str and it will return the formatted version of str where the first character is upper cased and the rest of lower cased, you will call this during the input phase so each item name stored in snackName array will all be formatted, and when the user enters an item code as a string it will format that input so it make it case insensitive

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!