Write a program to read in a text file of your own making


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:

Results:

Line 1: ‘' Balanced

Line 2: ‘' Unbalanced

.

.

.

Line n: ‘' Balanced

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a program to read in a text file of your own making
Reference No:- TGS02873566

Expected delivery within 24 Hours