1 Write a Java program to read in a DSFM, then decides if an input string...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1 Write a Java program to read in a DSFM, then decides if an input string is accepted by the DSFM or not. You can assume the input DSFM is legal, and states are named with single letters. Note: The program has 2 parts: 1. Read in the start state, the final states, and the transitions of the input DSFM. (no need to read K or I since the transitions would imply those) Use a Vector to store the set of final states. Use a Vector to store the set of transitions. 2. Determine if an input string is accepted or rejected based on algorithm dfsmSimulate. String methods such as startsWith and substring are useful. The following run is for the DSFM described in Ex2-4-1: Enter start state:s Enter final states, 1 on each line. Enter to end: Enter transitions, 1 on each line with no ws: state, letter,state. Enter 8.8.8 to end s.b.t tract Enter input string, enter done to end: a Accept Enter input string, enter done to end: ab Accept Enter input string, enter done to end:abb Enter input string, enter done to end: aba Enter input string, enter done to endiabaa Accept Enter input string, enter done to end:abbb Reject Enter input string, enter done to end: b Accept Enter input string, enter done to end:bb Reject Enter input string, enter done to end: done 1 Write a Java program to read in a DSFM, then decides if an input string is accepted by the DSFM or not. You can assume the input DSFM is legal, and states are named with single letters. Note: The program has 2 parts: 1. Read in the start state, the final states, and the transitions of the input DSFM. (no need to read K or I since the transitions would imply those) Use a Vector to store the set of final states. Use a Vector to store the set of transitions. 2. Determine if an input string is accepted or rejected based on algorithm dfsmSimulate. String methods such as startsWith and substring are useful. The following run is for the DSFM described in Ex2-4-1: Enter start state:s Enter final states, 1 on each line. Enter to end: Enter transitions, 1 on each line with no ws: state, letter,state. Enter 8.8.8 to end s.b.t tract Enter input string, enter done to end: a Accept Enter input string, enter done to end: ab Accept Enter input string, enter done to end:abb Enter input string, enter done to end: aba Enter input string, enter done to endiabaa Accept Enter input string, enter done to end:abbb Reject Enter input string, enter done to end: b Accept Enter input string, enter done to end:bb Reject Enter input string, enter done to end: done
Expert Answer:
Answer rating: 100% (QA)
Answer and step by step explanation Part 1 import javautilScanner import javautilVector public class ... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these electrical engineering questions
-
Write a java program to compute all prime numbers less than equal to a given integer N using the algorithm "Sieve of Eratosthenes". The Sieve of Eratosthenes is a method used to compute all primes...
-
Write a Java program that simulates car racing, as shown in Figure 16.22(a). The car moves from left to right. When it hits the right end, it restarts from the left and continues the same process....
-
I want to write a java program to calculate the letter grades of each student in the class based on the scale shown on the course overview and the syllabus. Which type of decision structure would be...
-
Refer to the bolt strength problem 17.47. Assume = 6,050 and 5 100. Use the following 24 individual bolt strength observations to answer the questions posed. (a) Prepare a histogram and/or normal...
-
On-The-Mark Construction began operations on December 1. In setting up its accounting procedures, the company decided to debit expense accounts when it prepays its expenses and to credit revenue...
-
If Virtual Con had decided to slow its payment of accounts payable by 90 days instead of entering into a financing arrangement with the bank, what would be the impact on its operating cash flow (CFO)...
-
How to use the Internet to gather facts?
-
A consulting firm submitted a bid for a large research project. The firms management initially felt there was a 50/50 chance of getting the bid. However, the agency to which the bid was submitted...
-
Your company currently spends $10,000.00 per year to rent a light commercial shop facility. This cost inflates by 2% per year. For a nominal return rate of 6%, what is the real present value of the...
-
Every nonempty K-variety in F n may be written uniquely as a finite union V 1 U V 2 U U V k of affine K-varieties in F n such that V j V i for i j and each V i is irreducible (Exercise 8). Data...
-
GlenVine is considering a purchase of a new grape crusher to make their wine. This new crusher is much more efficient than the one that GlenVine currently uses which would result in an annual savings...
-
Consider the network shown in Figure-Q1.2. (No need to explain) A B C D Figure-Q1.2 E F (i)_[2 marks] The average degree (k)= (ii) [2 marks] The average distance of Node A to all other nodes (iii) [2...
-
Calculate the fair price of a 120-day forward contract for Company A's stock, On the spot market, Company A's stock is traded at $67, Company A will pay a dividend of $4 per share in 100 days. The...
-
Energy balance for a closed system can be defined as: The change in the amount of energy contained within a closed system during some time interval is always equal to zero; ensfar The change in the...
-
The free cash flow to the firm is reported as $300 million. The interest expense to the firm is $45 million. If the tax rate is 35% and the net debt of the firm increased by $30 million, what is the...
-
1. The kinetic energy of a skier at a small hill (Point A) and his potential energy are 120 kJ and 450 kJ, respectively. Then the skier slides down the smooth snow-covered hill to the flat leveled...
-
Assignment Objective Implement and test an ORDERED linked list of integer nodes using references (as opposed to an array). Implementation Details Use the following implementation of IntegerNode.java...
-
Proposals have been made to ?sail? spacecraft to the outer solar system using the pressure of sunlight, or even to propel interstellar spacecraft with high-powered, Earth-based lasers. Sailing...
-
Suppose that we would like to perform a bird survey to count the number of birds of each species in an area. Create a class BirdSurvey that is like one of the linked-list classes given in this...
-
What output will be produced by the following code? public class Demo { public static void main(String[] args) { System.out.println("The output is:"); foo(23); System.out.println(); } public static...
-
Consider a class BasketballGame that represents the state of a basketball game. Its attributes are The name of the first team The name of the second team The score of the first team The score of the...
-
On July 31, 2020, Magnus's Muffins paid \(\$ 18,000\) for business insurance for the next year. Record the entries for the purchase of the insurance by recording it as an expense and then making a...
-
On November 1, 2020, Freya Albatter's orthodontic office received a \(\$ 2,500\) prepayment from a client for dental work to be performed on November 22. The appointment got postponed until January...
-
On April 1, 2020, you prepaid three months of rent for a total of \(\$ 18,000\). Give your adjusting entry to record rent expense at April 30, 2020. Include the date of the entry and an explanation....
Study smarter with the SolutionInn App