Wednesday, March 2, 2011

Can U Help Me Donetors

clip test by Stack ( POS1: Edit 2A, 2C)

Write a Java program which reads one character from standard input and checks whether the entered a valid parentheses Compounding with ([{}]) result.
examples of correct brackets:

 ()([])[[([])]]{} 
x {abc (sdf (c))} asx
asd ()
[]
((()) )
{{{(())}}}

examples of incorrect parentheses:

 (() 
[])
(([)])

The program is intended to indicate if the clipping is correct. The program will check all the clamps up EOF (in the examples above, each case is a command line!).
use to implement a (Self-programmed) Stack (class of its own):
 void push (char elem) / / element at the top of stack 
char pop () / / last element
boolean isEmpty () / / false if not empty

extension arguments to program and files


expand the program so that assistance can be issued multiple input files and an optional output file can be specified. An input file and a bracket expression (which may consist of several lines of course). If no input file specified, is to read from stdin .

Call:

 java brackets [-h  out] [inputfile ...] 
-h ... Help
out-o ... Output to the file out
input files ... optional multiple input files

detailed error messages


expand the program by issuing a detailed error message. Which error was found? Where the error was found (row / column)?
error

  wrong clip to  
too many parentheses to
enough staples to

0 comments:

Post a Comment