Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93067580

Have any Question?


Related Questions in Computer Engineering

Question social networks have become popular media among

Question : Social networks have become popular media among individuals of all ages to stay connected with friends, family, colleagues and coworkers. However, many users are unaware of the dangers of sharing vast amounts ...

Maureen has preferences for two goods to be consistent with

Maureen has preferences for two goods to be consistent with the utility function. The price of good 1 is $4 each, and the price of good 2 is $12 each. For what incomes will good 1 be normal?

Suppose after collecting data on an existing firms actual

Suppose, after collecting data on an existing firm's actual short-run ouput, the following production function is found to match the data:  TP = Q = 5*L + 0.6*L2 - 0.01*L3  1. Using the equation above, find the following ...

Refer to the cyclic redundancy check crc codes discussed in

Refer to the Cyclic Redundancy Check (CRC) codes discussed in the textbook and follow the conventions used in the textbook. Consider the 5-bit generator, G=10011, and suppose that D has the value 1010101011. What is the ...

The contracts manager at a company needs to make a large

The contracts manager at a company needs to make a large legal document available to an overseas customer. However, she has some challenges: The document contains sensitive information; it is too large to send via e-mail ...

Question suppose we want to build a b tree that has space

Question : Suppose we want to build a B+ tree that has space for 200,000 data entries in its leaf pages. Each data entry is made up of a key and its corresponding data value. Let us assume the following specifications. E ...

Frontier services has a 2000 pure discount bond that comes

Frontier Services has a $2,000 pure discount bond that comes due in one year. The risk-free rate of return is 4 percent. The firm's assets are expected to be worth either $2,800 or $1,600 in one year. Currently, these as ...

Assignment -question 1 - go-back-n in the following network

Assignment - Question 1 - (Go-Back-N) In the following network, node A transmits packets that pass through B and C, and arrive at the destination D. The bit rate of all links is R = 1 Mbit/sec. The maximum packet size in ...

C programmingneed help with a c program arrayrearrangec

***C PROGRAMMING*** Need help with a C program array_rearrange.c that rearranges an integer array. The array will be split into two sets of integers one by one. A new array will be created by append the first set to the ...

Need help with a java program that takes two arrays a and b

Need help with a Java program that takes two arrays a and b of length 5 storing int values, and returns the dot product of a and b. That is, it returns an array c of length n such that c[i]=a[i]*b[i].

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As