Test for balanced parenthesis and balanced brackets

Assignment Help Computer Engineering
Reference no: EM132080106

You need help wit this assignemnt.

Write a program to read in a text file (of your own making) and test for balanced parenthesis and balanced brackets. Call the file: "assn3data.txt". You can use Notepad (Win) or Textedit (Mac) to create the file, to make it easier on yourself - do not add any blank lines to the file.

Example of balanced parenthesis and brackets: ((x-y) + [n-1] / z )

Example of unbalanced parenthesis and brackets: ( a + b [ z + 1 ] ( z / 2)

The file can contain multiple lines, with each line having parenthesis and/or brackets. Each line will be self-contained, so you do not need to worry about matching parenthesis and brackets across multiple lines in the file. If a line does not contain any () or [] characters at all, consider it balanced.

You should use a stack data structure to test each line of the file for the balanced/unbalanced result.

Note: this program does not need to be recursive, but you can use recursion if you like.

Use a Queue data structure to hold and print out the results of the testing after all the lines in the file are processed. The Queue should hold the line number for each line of the file which was read in and the result (balanced or unbalanced) for each line number in the file. See example output below.

Your program should use a class, and have an object of that class which you instantiate and use. You should call methods to do most of the work in the program. Also, comment your code where appropriate. Every line does not need to be commented, but you should have a proper header, and each method should have some comments as well as a major section such as a loop, conditional statement or an abstract data type.

YOU MUST INSTANTIATE AN OBJECT OF YOUR OWN CLASS. NO MORE USING "public static" methods from this assignment on.

Make your output look like this example output:

File read in: <filename>

Results:

Line 1: ‘<display line here>' Balanced

Line 2: ‘<display line here>' Unbalanced

.

.

.

Line n: ‘<display line here>' Balanced

Reference no: EM132080106

Questions Cloud

What is the maximum number of simultaneous calls : What is the maximum number of simultaneous calls a CDMA system with a processing gain of 30 dB, an Eb/No of 13 dB and inter-cell interference factor.
What is the value after the following code executes : The point of this test was to see our knowledge of "braces" locations within the code. So this code is missing braces.
Set of reworks go off in the order : The most common colours in reworks are red, orange, yellow, green, blue, and purple. A student is watching a rework show and sees a set of reworks go off
Draw a truth table to represent the problem : Draw a truth table to represent the problem and use it to construct a Karnaugh map. Construct a circuit to implement the function using NAND gates only.
Test for balanced parenthesis and balanced brackets : Write a program to read in a text file (of your own making) and test for balanced parenthesis and balanced brackets. Call the file: "assn3data.txt".
What will the final temperature be in kelvin : The pressure doesn't change and the amount of gas in the balloon doesn't change.
Whams of a sample of umbo : The ponderosity in whams of a sample of umbo is directly proportional to the number of frenks in the sample and to its muckle, measured in flugges.
Write a code to reverse the order of the items in q : Write a C++ function void SelectItem(stack &S, ItemType n); that finds the first occurrence of item n on stack S and moves it.
What is the ph of a buffer solution : What is the pH of a buffer solution comprised of 3.95 M HCOOH and 0.35 M HCOO- in a 1 L solution after 0.30 mol NaOH (where Ka = 1.77 x 10-4) is added?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd