Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please write this program in c++ and use vectors and arrays. Hints are given in the last picture. Your program presents the user with a
Please write this program in c++ and use vectors and arrays. Hints are given in the last picture.
Your program presents the user with a choice of your favorite beverages. Then allow the user to choose a beverage by entering a pair of inputs. The output which beverage user chooses. Let A set of favorite beverages = {Coke, Pepsi, Water). Let B set of valid user input for above drinks = {(A, 1), (B, 2), (C, 3)} C1, C2, and C3 are the logic inputs. There are 8 possible truth values or 8 digital logic inputs. Only 3 pairs are valid for 3 favorite beverages. The machine can hold maximum 10 drinks for each of the logic inputs. Input/output Table for the vending machine The truth table and The Boolean Expression Corresponding to the Digital Circuit User Output Logic Output For output Input riable Display the drink cost from the keyboard ci C2 C3 o Invalid 0 0 0 0 Not available selection (1,1) Coke 0 0 1 1 $1.50 Invalid 0 1 0 0 Not available selection (B,2) Pepsi 0 1 1 1 $1.75 Invalid 1 0 0 0 Not available selection (C,3) Water 1 0 1 1 $1 Invalid 1 1 0 0 Not available selection Invalid 1 1 1 0 Not available selection Your program should operate continuously with a list of drinks and their costs displayed on the terminal. Example of the keypad: 12 INSTRUCTIONS B 13 14 1 For price of desired item press corresponding key 2 Price appears on display 3 Insert coins C5 6 D 17 18 # 9 110 Make selection on key pad Once a user has selected their drink the system should allow them to enter the amount of money they are inserting into the machine. The program should then calculate the amount of change to be returned and subtract one from the number of the drink in the machine. If the user selects a drink which has sold out an appropriate message should be displayed. Some input validation should be carried out on the selection from the true table. Array/vector must be used and an expected looping menu-driven of the keypad. Once a user has selected their drink, the system should allow user to enter the amount of money they are inserting into the machine. The program should then calculate the amount of change to be returned from the machine. Hints: C1, C2, C3 are the truth values. You can put these values into an array of size 8 since 2^3 =8. You can also map the the inputs A,1... to the array the corresponding truth values. Example of the truth table: bool truthTable[8][3] = { {0,0,0], {0,0,1}, {0,1,0}, {0,1,1}, {1,0,0}, {1,0,1), {1,1,0}, {1,1,1}, You can also use vectorStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started