Need Help ?

Home / Expert Answers / Other / inc-please-consider-the-finite-state-machine-shown-below-that-controls-a-two-story-elevator-the-elev

(Answered): InC please Consider the finite state machine shown below that controls a two story elevator. The ele ...




Consider the finite state machine shown below that controls a two story elevator. The elevator has a toggle button that can bFirst, define two additional enumerations named State and LED to represent the values GROUND and FIRST, and RED and GREEN, reInC please
Consider the finite state machine shown below that controls a two story elevator. The elevator has a toggle button that can be in the UP position or the DOWN position, and an LED light that can be RED or GREEN. When the elevator is on the GROUND floor the light is RED, and when the elevator is on the FIRST floor the light is GREEN. UP DOWN GROUND FIRST UP DOWN Assume the existence of function enum Button getButton(); that returns a value of DOWN or UP, given enumeration enum Button {DOWN, UP); Note the function getButton() already exists so you do not need to define this function, you just need to call this function. First, define two additional enumerations named State and LED to First, define two additional enumerations named State and LED to represent the values GROUND and FIRST, and RED and GREEN, respectively. Second, write an infinite while loop that first sets the value of a variable that represents the color of the led to either RED or GREEN according to which floor the elevator is currently stationed. Then call function getButton() to read the current position of the toggle button and reassign the value of a variable to represent the next desired floor state of the elevator to either GROUND or FIRST. Assign the elevator to initially reside on the GROUND floor, and assume the elevator moves infinitely fast and will move to the desired floor immediately when the floor state variable is reassigned. Only show the enumerations and while loop code. Do not define any functions or an entire program with a main function.


We have an Answer from Expert

View Expert Answer

Expert Answer


Answer to Consider the finite state machine shown below that controls a two story elevator. The elevator has a toggle button that ...
We have an Answer from Expert

Buy This Answer $4

Place Order