Create a program that should read in character from the file

Assignment Help Data Structure & Algorithms
Reference no: EM131119687

charStack

Given a text file, your program will determine if all the parentheses, curly braces, and square brackets match, and are nested appropriately. Your program should work for mathematical formulas and most computer programs.

Your program should read in the characters from the file, but ignore all characters except for the following: { } ( ) [ ]

The general algorithm is to use a stack to store the opening unmatched brackets. When a closing bracket is encountered, check it against the one on top of the stack (pop it off)--make sure it matches. When you are finished there should be no unmatched brackets left on the stack.

Your program should first implement a char stack. CharStack.h is provided on the website. You must supply the CharStack.cpp file that includes the implementations of the functions in the class declaration. Note that the stack elements will be stored in a string, and no variable named top is necessary. You can complete this assignment using these string functions: at(int), size(), append() or +=, and substr(int, int). Note: Do NOT use these functions: push_back, pop_back, or back.

Input/Output:

Your Driver program must prompt the user to enter a filename. It should then try to open the file and then check it make sure the brackets all match appropriately. If they all match, the program should output a message saying so. If not, the program should output an appropriate error message.

There are three types of errors that can happen (and they can happen with any kind of bracket):

missing } : if you reach the end of the file, and there is an opening { that was never matched, like: int main () { x[size]=10;

expected } but found ) : this is a wrong closing bracket, like: {x[i]=10;)... unmatched } : this occurs if there is a closing bracket but not an opening bracket

(not even one of the wrong kind), like: int main () { x[i]=10; } }...

Reference no: EM131119687

Questions Cloud

What problems may be indicated by an average collection : What problems may be indicated by an average collection period that is substantially above or below the industry average?
What are the ethical arguments : What are the ethical arguments for or against private corrections?
How has the history of healthcare compliance changed : How has the history of healthcare compliance changed since its inception? Hint: Look at the ways in which penalties have increased in various ways. What do you think will be the key to getting control of the issue of fraud and abuse in the future
The initial down payment has not been earned and collection : What entry would be made by Campbell on January 1, 2010, if the down payment is refundable and substantial future services remain to be performed by Campbell?
Create a program that should read in character from the file : Your program should read in the characters from the file, but ignore all characters except for the following: { } ( ) [ ]. The general algorithm is to use a stack to store the opening unmatched brackets.
What is the major limitation of the current ratio : What is the major limitation of the current ratio as a measure of a firm’s liquidity? How may this limitation be overcome?
How does the correctional subculture differ : How does the correctional subculture differ from the police subculture in regards to corrupt practices? How are they similar?
What is project crashing : What is "project crashing"? When might it be appropriate to utilize project crashing? What are the potential downfalls of project crashing
What are the primary limitations of ratio analysis : What are the primary limitations of ratio analysis as a technique of financial statement analysis?

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Describe an algorithm for sorting

The integers are NOT sorted and you CANNOT sort them. You need to see if the numbers would match the pattern if you were to sort them.

  Create the shoutbox class for your virtual world

Create the ShoutBox class for your Virtual World. Your ShoutBox class will have two methods - initialize your data structures with words or have the user enter the words

  You used the same dataset to analyze both

You used the same dataset to analyze both a between- and within-subjects design. Create a single paragraph (using the material you wrote above), that presents both sets of results.

  Devise ef?cient algorithm for computing probability

Given the probabilities r1, · · · , rn, the costs c1, · · · , cn, and the budget B, ?nd the redundancies m1, · · · , mn that are within the available budget and that maximize the probability that the system works correctly. Devise an ef?cient algo..

  Identify a function to map the canonical name

Identify a function to map the canonical name to the DB2 name and identify the corresponding name (local DB2 name) of the same field in DB2

  Write efficient backtracking algorithm to inputs integers

Write efficient backtracking algorithm which inputs the integer N, and outputs all of the ways which a group of ascending positive numbers can be summed to N.

  Different network connections

Use your laptop at public store to check your email and discuss all the different network connections involved in this operation.

  Write program that implement a binary search of sorted array

Write and test a program that instantiates a function template that returns the minimum of two values. Write and test a program that instantiates a function template that implements a binary search of a sorted array of objects.

  Create a binary search tree

Create a Binary Search Tree

  Data systems and design

Suppose if you have a program with a housekeep() module, a mainloop() module, and a finishup() module, when is the second input record usually read?

  Perform functional decomposition and build data flow diagram

For the next level (Level 2), only decompose one of the processes from Level 1. Your answer will consist of 3 PowerPoint slides - one for the Context, one for Level 1, and one for the decomposition of one of the Level 1 processes into Level 2. Per..

  How do a bubble sort in mips?

How do a bubble sort in MIPS?

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