Development DocumentBriefThe utility app assignment is to make a virtual ‘Vending Machine’ programmed in C++. Theassignment has a set of minimum requirements that should reflect techniques learnt in class.There are opportunities for extra features to be added in order to gain extra marks usingtechniques learnt outside of class.SpecificationMinimum features:● A menu of drinks and snacks presented via the console.● A set of codes that the user can input to select a particular drink or snack.● A way of capturing the user’s inputted code.● A way of managing money allowing the user to input money and calculate change.● A message that tells the user that a particular drink or snack has been dispensed.● A message that tells the user how much change they have received.● Comments in the code explaining key operations.Additional features:● A method of categorising items in the vending machine to improve the user experience.● A way of allowing users to buy additional items if they have enough money.● The use of functions to improve the structure of my program.● A way of letting the user input more money into the machine.● The use of changing the text colour to improve the user experience.● A way of letting the user move between the item and category menus.System FlowchartTechnical DescriptionKey: Functions, Data Types, ArraysThe program makes use of functions in order to split up three operations that the vendingmachine needs to handle separately. These operations are when the user inputs money into themachine, when the user selects an item category and when the user selects an item topurchase. As an example, the function addMoney is called on three separate occasions. Whenthe main function first loads it calls addMoney as the user needs to input money into themachine before they can purchase anything from the machine. It is then called in thecategoryChoice function in a switch statement so the user can have the option to input moremoney into the machine if they do not have enough to purchase the items they want. It is alsocalled in the itemChoice function after the user has successfully purchased an item so theyhave the option to input more money in order to keep purchasing more items.The program makes use of while-loops, do-while loops and switch statements in order processuser inputs when selecting from a menu in the vending machine. An example of this is when theuser selects a category from the first menu in the categoryChoice function.First, the input, called categoryInput, is passed into a while-loop. The categoryInput needs to bean integer in order to be processed by the switch statement. The while-loop is used when theinput is not an integer. If this is the case, the loop outputs an error message to the console, thenasks the user to input a valid integer again.If the user enters an integer then categoryInput is passed into the switch statement. If the inputis not one of the cases in the switch statement, the default case is selected. The default caseprints an error message to the console. It then asks the user to enter another choice and thensets the boolean “loop” to true. This then loops back to the while statement. Both the while loopand switch statement are contained in a do-while loop which keeps looping until the user entersa valid input.The program also makes use of arrays and for-loops to display item names and prices when theuser selects a category. There are ten item arrays in the program, with five being string arrayscontaining item names and five being integer arrays containing item prices. Each array is for acertain category of item. For example, the potions list is two arrays of potionNames andpotionPrice. When a user selects the potion category, the list of potion names and prices isdisplayed via a for-loop. The for-loop loops through each array five times and displays the stringand integer stored at that position to make a list.Critical EvaluationI think one of the best elements of my program is the effective way I displayed item menus.Instead of directly hard-coding the item lists in large switch statements I decided to use for-loopsand display the item names and prices from an array. This worked very well when I split up theitems into different categories. Each item category was given its own array, and the array wouldbe selected depending on which category the user selected.I think another element of my program that worked really well was how I used functions to splitup frequently used processes. An example of this is the function I made for when the userneeded to input additional money into the machine. This function took a users input and added itto the balance of the machine and significantly reduced the lines of code I used in the program.One thing I think I could have improved about my utility app was how errors were handled.While my program detects errors, it does not clear the screen after telling the user that theyentered an invalid input. This results in the menu being lost at the top of the screen if the userenters an invalid input too many times. The reason I could not clear the screen is that of the wayI handled the input errors. If I cleared the screen I would not be able to display the menu againwithout unnecessarily large amounts of code. I could improve this in the future by handing inputerrors slightly differently.Another thing I think I could have improved is how items were handed in the vending machine.The program in its current state dispenses items one at a time with specific times you can enteraddition money in order to purchase more. I think the vending machine would have workedbetter if I allowed the user to purchase multiple items at once in a ‘basket’. The machine wouldthen dispense them all at the end along with the change.
- Assignment status: Already Solved By Our Experts
- (USA, AUS, UK & CA PhD. Writers)
- CLICK HERE TO GET A PROFESSIONAL WRITER TO WORK ON THIS PAPER AND OTHER SIMILAR PAPERS, GET A NON PLAGIARIZED PAPER FROM OUR EXPERTS