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

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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