Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Construct a finite-state machine that models an old-fashioned soda machine that accepts nickels, dimes, and quarters. The soda machine accepts change until 35 cents has been put in. It gives change back for any amount greater than 35 cents. Then the customer can push buttons to receive either a cola, a root beer, or a ginger ale.

Short Answer

Expert verified

The finite-state machine that models an old-fashioned soda machine is shown below:

Step by step solution

01

General form

Finite-State Machines with Outputs (Definition):

A finite-state machine\({\bf{M = }}\left( {{\bf{S,}}\,\,{\bf{I,}}\,\,{\bf{O,}}\,\,{\bf{f,}}\,\,{\bf{g,}}\,\,{{\bf{s}}_0}} \right)\)consists of a finite set S of states, a finite input alphabet I, a finite output alphabet O, a transition function f that assigns to each state and input pair a new state, an output function gthat assigns to each state and input pair output and an initial state\({{\bf{s}}_0}\).

Formulae to be used:

1 Nickels = 5 cents

1 Dimes = 10 cents

1 Quarters = 25 cents

02

Step 2: Construct a finite-state machine model

Given that an old-fashioned soda machine that accepts nickels, dimes, and quarters. The soda machine accepts change until 35 cents has been put in.

It gives change back for any amount greater than 35 cents. Then the customer can push buttons to receive either a cola, a root beer, or a ginger ale.

Construction:

Let us consider the states\({{\bf{s}}_{\bf{i}}}\), where\({\bf{i = 0,1,2,3,4,5,6,7}}\).

The states will represent that the machine contains 0, 5, 10, 15, 20, 25, 30, and 35 cents respectively.

If we add a nickel to the machine, then the input is 5 to the current state \({{\bf{s}}_{\bf{i}}}\). We then move to \({{\bf{s}}_{{\bf{i + 1}}}}\) and the output is 0. As we don’t return any money.

If we add a dime to the machine, then the input is 10 to the current state \({{\bf{s}}_{\bf{i}}}\). We then move to \({{\bf{s}}_{{\bf{i + 2}}}}\). If \({{\bf{s}}_{{\bf{i + 2}}}}\) does not exist and the output is the money that gest returned.

If we add a quarter to the machine, then the input is 25 to the current state\({{\bf{s}}_{\bf{i}}}\). We then move to \({{\bf{s}}_{{\bf{i + }}5}}\). If \({{\bf{s}}_{{\bf{i + }}5}}\) does not exist and the output is the money that gest returned.

Let x represent that we hit the button for soda pop. If we are not at state \({{\bf{s}}_7}\), then hitting the button does nothing. If we are at state \({{\bf{s}}_7}\), then we return a soda pop and return at the starting state.

The model of the finite-state machine is shown below:

Therefore, the result shows the required finite-state machine.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Describe the set of strings defined by each of these sets of productions in EBNF.

\(\begin{array}{c}\left( {\bf{a}} \right){\bf{string :: = L + D?L + }}\\{\bf{L :: = a }}\left| {{\bf{ b }}} \right|{\bf{ c }}\\{\bf{D :: = 0 | 1}}\\\left( {\bf{b}} \right){\bf{string :: = signD + |D + }}\\{\bf{sign :: = + | - }}\\{\bf{D :: = 0 | 1|2|3|4|5|6|7|8|9}}\\\left( {\bf{c}} \right){\bf{string :: = L*}}\left( {{\bf{D + }}} \right){\bf{?L* }}\\{\bf{L :: = x |y }}\\{\bf{D :: = 0 | 1}}\end{array}\)

Construct phrase-structure grammars to generate each of these sets.

a) \(\left\{ {\left. {{\bf{0}}{{\bf{1}}^{{\bf{2n}}}}} \right|{\bf{n}} \ge {\bf{0}}} \right\}\)

b) \(\left\{ {\left. {{{\bf{0}}^{\bf{n}}}{{\bf{1}}^{{\bf{2n}}}}} \right|{\bf{n}} \ge {\bf{0}}} \right\}\)

c) \(\left\{ {\left. {{{\bf{0}}^{\bf{n}}}{{\bf{1}}^{\bf{m}}}{{\bf{0}}^{\bf{n}}}} \right|{\bf{m}} \ge {\bf{0}}\,{\bf{and}}\,{\bf{n}} \ge {\bf{0}}} \right\}\)

Show that a set is generated by a regular grammar if and only if it is a regular set.

Let V = {S, A, B, a, b} and T = {a, b}. Find the language generated by the grammar (V, T, S, P) when theset P of productions consists of

\(\begin{array}{*{20}{l}}{{\bf{a) S }} \to {\bf{ AB, A }} \to {\bf{ ab, B }} \to {\bf{ bb}}{\bf{.}}}\\{{\bf{b) S }} \to {\bf{ AB, S }} \to {\bf{ aA, A }} \to {\bf{ a, B }} \to {\bf{ ba}}{\bf{.}}}\\{{\bf{c) S }} \to {\bf{ AB, S }} \to {\bf{ AA, A }} \to {\bf{ aB, A }} \to {\bf{ ab, B }} \to {\bf{ b}}{\bf{.}}}\\{{\bf{d) S }} \to {\bf{ AA, S }} \to {\bf{ B, A }} \to {\bf{ aaA, A }} \to {\bf{ aa, B }} \to {\bf{ bB, B }} \to {\bf{ b}}{\bf{.}}}\\{{\bf{e) S }} \to {\bf{ AB, A }} \to {\bf{ aAb, B }} \to {\bf{ bBa, A }} \to {\bf{ \lambda , B }} \to {\bf{ \lambda }}{\bf{.}}}\end{array}\)

Construct a Moore machine that determines whether an input string contains an even or odd number of 1s. The machine should give 1 as output if an even number of 1s are in the string and 0 as output if an odd number of 1s are in the string.

See all solutions

Recommended explanations on Math Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free