Question
I have updated the question. Please modify the c++ code below by adding the boolean truth table list shown in the picture. #include using namespace
I have updated the question.
Please modify the c++ code below by adding the boolean truth table list shown in the picture.
#include using namespace std;
// {"drink",{price, stock}} unordered_map > drinks; vector beverages;
vector code = {"A1", "B2", "C3", "D4", "E5", "F6", "G7", "H8"};
void action() { char input; do { cout p : drinks) { cout > choice; if (choice[1] == '#') return; int beverageId = -1; if ((choice[0] - 'A') >= 0 && (choice[0] - 'A')
if (drinks[beverages[beverageId]].second > 0) { drinks[beverages[beverageId]].second--; int money = 0; char ch = 'y'; // while loop to collect amount from the user while (ch != 'n') { cout > amountEntered; if (amountEntered != 1 && amountEntered != 5 && amountEntered != 10) { cout = drinks[beverages[beverageId]].first) break; cout > ch; } if (money > input; if (input == 'n') cout
int main() { // if the technician enters the passcode "0000#" he can change the menu // else the user will be directed to the buying section string passcode; cout > passcode; while (passcode == "0000#") { // technician menu cout > choice; if (choice == "1") { string drink; int items; double price; cout > drink; cout > price; cout > items; beverages.push_back(drink); drinks[drink].first = price; drinks[drink].second = items; } else if (choice == "2") { string drink; cout > drink; int found = -1; for (int i = 0; i > drink; int found = -1; for (int i = 0; i > drinks[beverages[found]].first; cout 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}, }; 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. A service technician enters 0000# from the keypad, your program presents a menu and operates continuously until user exit the menu: 1) Add new beverage 2) Remove beverage 3) Update beverage price A service technician can also reprogram the logical truth values for C1, C2, C3 for any of the favorite beverages. The vending machine can be programed up to 8 favorite beverages for 8 possible truth values for C1, C2, C3. Once the vending machine is programed, your program presents the user with a choice of the favorite beverages. Then allow the user to choose a beverage by entering a pair of input. The output which beverage user choses. Let A set of favorite beverages = {al, al, a2, a3, a4, a5, a6, a7} such that al, al..., a7 can be any favorite beverages. Let B set of valid user input = {(A, 1), (A, 2), (A, 3), ... (DO)} such that any ordered pair can be re-programed for any of the favorite beverage in set A. Output Input For output Display the drink cost User Input from the keyboard Any element in set B Any element in set B any C1 C2 C3 any 0 0 0 Price is programmable Any any 0 0 1 Price is programmable any 0 1 0 Price is programmable element in set B Any element in set B Any element in set B Any element in set B any 0 1 1 Price is programmable any 1 0 0 Price is programmable any 1 0 1 Price is programmable any 1 1 0 Price is programmable Any element in set B Any element in set B Any element in set B any 1 1 1 Price is programmable 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}, }; 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. A service technician enters 0000# from the keypad, your program presents a menu and operates continuously until user exit the menu: 1) Add new beverage 2) Remove beverage 3) Update beverage price A service technician can also reprogram the logical truth values for C1, C2, C3 for any of the favorite beverages. The vending machine can be programed up to 8 favorite beverages for 8 possible truth values for C1, C2, C3. Once the vending machine is programed, your program presents the user with a choice of the favorite beverages. Then allow the user to choose a beverage by entering a pair of input. The output which beverage user choses. Let A set of favorite beverages = {al, al, a2, a3, a4, a5, a6, a7} such that al, al..., a7 can be any favorite beverages. Let B set of valid user input = {(A, 1), (A, 2), (A, 3), ... (DO)} such that any ordered pair can be re-programed for any of the favorite beverage in set A. Output Input For output Display the drink cost User Input from the keyboard Any element in set B Any element in set B any C1 C2 C3 any 0 0 0 Price is programmable Any any 0 0 1 Price is programmable any 0 1 0 Price is programmable element in set B Any element in set B Any element in set B Any element in set B any 0 1 1 Price is programmable any 1 0 0 Price is programmable any 1 0 1 Price is programmable any 1 1 0 Price is programmable Any element in set B Any element in set B Any element in set B any 1 1 1 Price is programmable
Step 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