Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Foundations of Computer Science: computer operating systems Homework 02 Input file of test cases: ( Below) If your program works correctly according to the specifications,

Foundations of Computer Science: computer operating systems

Homework 02

Input file of test cases: ( Below) If your program works correctly according to the specifications, then you should be able to pipe [ https://en.wikipedia.org/wiki/Pipeline_(Unix) ] in this file to run all of the test cases. The y and n in the input file do not represent that the string is in the language or not. Instead, y tells your program to read another input string, and n tells your program to stop; see the program specifications in Section 4 of the assignment. You do not have to use the input file to run the test cases, but the input file is provided just to make it easier to run them all using a pipe. Also, you dont have to use pipe, but it can make it easier when debugging to run all of the test cases without having to type them all in.

===============

testCases.txt

y foo@abcd.com y z@c.com y ba@ba.co y cdef@.com y webweb.a.b.c.d.e@z.ai.cs.stanford.com y foo@goo.com..com y abqe.@boom.com y comp@comp.com. y redblue@green..com y random@com y poke@a.com.com y www@com.comp y wwwb@com.co y .two@three.com y food@for.com@ y comp@company.co.com y computer@company.com.co y @abcde.com y people.dog.cat@.com y cable..cord@fort.com n

===========================

Program Specifications

You must write your program in either C, C++, Java, or Python. All input/outputmust be through standard input/output, and your program is to work as follows:

Your program next asks the user if s/he wants to enter a string. The user thenenters y for yes, or n for no.If the user enters n, then the program terminates.If the user enters y, then the user is prompted to enter a string over.

3. If the user chooses to input a string, your program then readsin the string. Afterreading in the string, your program prints it.

Then your program processes theentirestring on the DFA, one character at a time, in the following manner.Your program must begin in the start state of the DFA and print outthename of that state (q1orq0). After each character from the string is processed on the DFA, your programmust print out the character and the name of the current state of the DFA.Even if your DFA is in a trap state, your program must do this for eachcharacter in the string until it reaches the end of the string.To simplify your program, you can check the ASCII code of each character of thestring and process on the DFA accordingly.

4. After processing the entire string on the DFA, your program must indicate if thestring is accepted or rejected based on the state in which the DFA ended. Yourprogram then should return to step 2.

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

Explain the shape of the efficient frontier.

Answered: 1 week ago