Question: model this system as a FSM. Vending Machine allows users to deposit coins and push a button to dispense product, or a button to cancel

model this system as a FSM.

Vending Machine allows users to deposit coins and push a button to dispense product, or a button to cancel and get all deposited money back. 2 separate places: the currentBin and the bank. When product is dispensed currentBin is transferred to bank. On cancel, currentBin is returned. Product is only dispensed if currentBin >= 50 cents.

Commands: d (dime), q (quarter), D(dispense),C(cancel)

model this system as a FSM. Vending Machine allows users to deposit

INIT: Initial state, the machine is waiting for the first coin deposit.

WAIT_FOR_CMD: The machine has received at least 50 cents and is waiting for a command from the user.

DISPENSING: The machine is in the process of dispensing the product.

DISPENSED: The machine has dispensed the product or not, depending on whether the current bin had enough money.

CANCEL: The machine is returning the money to the user.

Actions

: deposit: The user deposits coins (dimes or quarters).

dispense: The user requests to dispense the product.

dispensed: The machine dispenses the product if there is enough money in the current bin, otherwise it stays in the WAIT_FOR_CMD state.

cancel: The user requests to cancel and get their money back.

Write a program (any language) that simulates the vending machine, based on your FSM. The entire content of the FSM, including that appropriate output, should be hard- coded as a table. The entire simulation should look almost exactly like the program below, and the table(s) should correspond to your FSM (if your original FSM wasnt appropriate, make a new one.

Main State = 0

While(true) //this is an ongoing system with no end.

Cmd = input from keyboard

Output out[state][cmd]

State = newstate[state][cmd]

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!