Reference no: EM13811696
Compilers check programs for syntax errors, but frequently a lack of one symbol (such as a missing brace or comment starter) will cause the compiler to spill out a number of diagnostics without identifying the real error. A useful tool in this situation is a program that checks whether every pair of symbols is balanced. Thus, every right brace, bracket, and parenthesis must correspond to its left counterpart. For instance, the sequence [()] is legal, but [(]) is not.
In this assignment, you are asked to write a balance-symbol checker which checks for the following pairs of symbols in the source code files of Java programs: (), [], {}. This checker must implement the following algorithm:
1. Make an empty stack.
2. Read symbols until the end of the source code file.
a. If the symbol is an opening symbol, push it onto the stack.
b. If it is a closing symbol, do the following:
i. If the stack is empty, report an error.
ii. Otherwise, pop the stack. If the symbol popped is not the corresponding opening symbol, report an error.
3. At the end of the file, if the stack is not empty, report an error.
As the algorithm above shows, a stack data structure must be used in this programming assignment. You are encouraged to use the Stack class available in the collections package of the Java API.
Input
Your program must take as input the name of a Java source code file such as the source file containing the source code of this assignment.
Write an essay on your short term personal financial and car
: Write an essay on your short term personal financial and career goals and the tentative plan on how you will achieve them.
|
For initial public offerings of common stock
: For initial public offerings of common stock, 2010 was a relatively slow year, with about $30.7 billion raised by the process. Relatively few of the 94 firms involved paid cash dividends. Why do you think that most chose not to pay cash dividends? Ex..
|
The affect of language between speakers and listeners
: How does language affect the relationship between speakers and listeners
|
Process design for the production
: Using the Six Sigma DMAIC process, develop a new process design for the production of the Riordan electric fans. Be sure to take advantage of any global opportunities available to Riordan, such as lower labor costs.
|
Compilers check programs for syntax errors
: Compilers check programs for syntax errors, but frequently a lack of one symbol (such as a missing brace or comment starter) will cause the compiler to spill out a number of diagnostics without identifying the real error
|
Calibration of new production equipment
: Mary Chong, capital expenditure manager for PDA Manufacturing, knows that her company is facing a series of monthly expenses associated with installation and calibration of new production equipment. The company has $1 million in a bank account right ..
|
If the volatility of each investment is 8 then find the valu
: 1. The current price of a bond is 100. The instantaneous rate of change or derivative of the price of the bond with respect to the yield rate is 700. The yield rate is an annual effective rate of 8%. Calculate the Macaulay duration of the bond. Note:..
|
How college students outside our class view graphic novels
: Conduct a small study to discover how college students outside our class view graphic novels. Then select an idea, theme, or minute detail related to WWII that you learned about by reading Maus.
|
Present value of perpetuity-when dealing with estate taxes
: Stock A has a current price of $40.00, a beta of 2.5, and a dividend yield of8%. If the Treasury bill yield is 5% and the market portfolio is expected to return15%, what should stock A sell for at the end of an investor’s three year horizon? What is ..
|