Compilers check programs for syntax errors

Assignment Help JAVA Programming
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.

Reference no: EM13811696

Questions Cloud

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 ..

Reviews

Write a Review

 

JAVA Programming Questions & Answers

  Prepare an address book to save the complete information

Prepare an address book to save the complete information of the person - Define the class Address that can store a street address, city, state, and zip code. Use the appropriate methods to print and store the address.

  Develop a reservation system program for specific flights.

develop a reservation system program for specific flights. A customer should be able to select from one of four categories of seats on flights from RDU to any of at least three other destinations. Based on the user input of seat type and destination,..

  Develop a program that will handle a golfer and his scores

develop a program that will handle a Golfer and his scores. The program will be comprised of two classes: a Golfer class that will manage all the golfer's scores and a Score class.This is a class designed to represent a golfer including his name, hom..

  Write a program that prompts the user to enter the mass

Write a program that prompts the user to enter the mass of a person in kilograms and outputs theequivalent weight in pounds. Output both the mass and the weight rounded to two decimalplaces. (Note that for standard Earth gravity, 1 kilogram = 2.2 pou..

  Write a program that takes cents as an integer and converts

Write a program that takes cents as an integer and converts it to dollars and cents and the conversion should be done in a function called NormalizeMoney.

  Be sure to show all declarations

Write a function call that invokes function a. Be sure to show all declarations. However a complete main is not required.

  What makes a program easy to modify

Describe the order of magnitude of the code section using Big(O) notation and Explain the relationship between dynamic storage allocation and recursion.

  Prepare worlddataapp project it implements the nameindex

prepare worlddataapp project. it implements the nameindex portion includingbull creating it implemented as a binary

  Create a histogram bar

Demonstrates an example of the user interface during your program's execution

  Implement the employee class and its three child classes

Implement the Employee class and its three child classes (ManagementEmployee, EngineeringEmployee and AdministrationEmployee), with all the necessary attributes and methods.

  Define a static max method in the geometricobject class

Modify the GeometricObject class to implement the Comparable interface, and define a static max method in the GeometricObject class for finding the larger of two GeometricObject objects

  Generate and manipulate music and images

Arrays are a fundamental and versatile tool for representing data of all shapes and sizes In this assignment, you'll see how arrays can be applied to generate and manipulate music and images.

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