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 a newspaper vending machine that has a door that can be opened only after either three dimes (and any number of other coins) or a quarter and a nickel (and any number of other coins) have been inserted. Once the door can be opened, the customer opens it and takes a paper, closing the door. No change is ever returned no matter how much extra money has been inserted. The next customer starts with no credit.

Short Answer

Expert verified

The finite-state machine that models a newspaper vending 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 g that 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 a newspaper vending machine that has a door that can be opened only after either three dimes (any number of other coins) or a quarter and a nickel (and any number of other coins) have been inserted.

Once the door can be opened, the customer opens it and takes a paper, closing the door.

No change is ever returned no matter how much extra money has been inserted. The next customer starts with no credit.

Construction:

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

We arrange the 9 states in 3 rows and 3 columns. The bottom row will represent that a first nickel was inserted and the top row will represent that a first quarter was inserted.

If we add a dime, then we will move to the state to the right or to \({{\bf{s}}_0}\) when it is the third dime.

If we add a nickel, then we move to the state below if no quarter was added previously and no nickel was added previously or we remain at the current state when no quarter was added previously and nickel was added previously or we move to the starting state if a quarter was added previously.

If we add a quarter, then we move to the state above if no nickel was added previously and no quarter was added previously or we remain at the current state when no nickel was added previously and a quarter was added previously or we move to the starting state if nickel was added previously.

Once three dimes or quarter + nickel have been inserted, the customer receives the paper and the algorithm moves back to the start state. Otherwise, the output is always 0 as no money is returned.

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

Let \({\bf{G = }}\left( {{\bf{V, T, S, P}}} \right)\) be the context-free grammar with \({\bf{V = }}\left\{ {\left( {\bf{,}} \right){\bf{S,A,B}}} \right\}{\bf{, T = }}\left\{ {\left( {\bf{,}} \right)} \right\}\) starting symbol \({\bf{S}}\), and productions

Show that \({\bf{L}}\left( {\bf{G}} \right)\) is the set of all balanced strings of parentheses, defined in the preamble to Supplementary Exercise \(55\) in Chapter \(4\).

In Exercises 16โ€“22 find the language recognized by the given deterministic finite-state automaton

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}\)

Describe the elements of the set \({{\bf{A}}^{\bf{*}}}\)for these values of A.

a){10}b){111}c){0, 01}d){1,101}

Give production rules in Backusโ€“Naur form that generate all identifiers in the C programming language. In โ€˜Cโ€™ an identifier starts with a letter or an underscore (_) that is followed by one or more lowercase letters, uppercase letters, underscores, and digits.

Several extensions to Backusโ€“Naur form are commonly used to define phrase-structure grammars. In one such extension, a question mark (?) indicates that the symbol, or group of symbols inside parentheses, to its left can appear zero or once (that is, it is optional), an asterisk (*) indicates that the symbol to its left can appear zero or more times, and a plus (+) indicates that the symbol to its left can appear one or more times. These extensions are part of extended Backusโ€“Naur form (EBNF), and the symbols?, *, and + are called metacharacters. In EBNF the brackets used to denote nonterminal are usually not shown.

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