Hello anyone who can help me to figure out how to do a problem to run with JDK 1.2
The Questions:
Write a program that determines whether parenthetic symbol ( ), [ ], { }, and <> are nested correctly in a string of characters. Your program should read a string from the user and display whether the string is parenthetically correct i.e. balancing the parenthesis.
The program written must use a stack to determine whether the string is parenthetically correct. It can use standard Java stack class or write own. If there is more than one class in the written program, put all classes in the same source file.
If the string is correct, displat the first character position (left to right, starting from 0) at which the program finds an error. Keep reading until the users enter an empty string.
Example.
Enter a string: (xy) ( pq [q-y] )
OK
Enter a string: ( ( [ [ a ] ) ] )
Error at position 6 : Found ) expected ]
*******Thank you for helping******
The Questions:
Write a program that determines whether parenthetic symbol ( ), [ ], { }, and <> are nested correctly in a string of characters. Your program should read a string from the user and display whether the string is parenthetically correct i.e. balancing the parenthesis.
The program written must use a stack to determine whether the string is parenthetically correct. It can use standard Java stack class or write own. If there is more than one class in the written program, put all classes in the same source file.
If the string is correct, displat the first character position (left to right, starting from 0) at which the program finds an error. Keep reading until the users enter an empty string.
Example.
Enter a string: (xy) ( pq [q-y] )
OK
Enter a string: ( ( [ [ a ] ) ] )
Error at position 6 : Found ) expected ]
*******Thank you for helping******