Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A finite state machine is a device or model application where the device or model is in one of several discrete states at any given

A finite state machine is a device or model application where the device or model is in one of several discrete states at any given time and based on the current state it can transition to a limited number of subsequent states.
For instance, a traffic light can be in one of three states: red, yellow, or green. If it is in the green state it can only transition to the yellow state. In the yellow state it can only transition to the red state and so on. It is never red and yellow at the same time nor do the colors occur at random.
Below is a model of a finite state machine: a candy machine. Based on its current state there has been 10 cents deposited only a few discrete states can occur afterward:
More money can be deposited.
Candy can be delivered.
Candy can be delivered with change.
Your task for this lab is to describe transitions in a traditional function style, if not functions designed using the syntax of a popular language. For this exercise you may ignore the process of delivering change after candy is dispensed, and you need not worry about returning money before candy is dispensed (eg. a coin return button).
Here is an example to start you off:
This is C language syntax:
int addnickel(int currentbalance){
int newbalance;
if(currentbalance ==0)
newbalance=5;
if(currentbalance ==5)
newbalance=10;
if(currentbalance ==10)
newbalance=15;
if(currentbalance ==15)
newbalance=20;
if(currentbalance ==20){
deliver candy;
newbalance=0;
//machine resets;
}
return newbalance;
In this example you can see that all of the 5 states beyond start involving a nickel are represented.
Design your functions below and return the completed document in the space provided in uLearn.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions

Question

find all matrices A (a) A = 13 (b) A + A = 213

Answered: 1 week ago