Java: How to implement the interface?

Write a Java program to implement Symbol balancing using a StackYou have to use the operations given in the Stack interface. Read a string of symbols which are comma separated from the key board.

  • Answer:

    First off, read the String from the keyboard. Secondly, split it on a comma. Thirdly, cycle over the split values. If the current iteration is less than half the length of the array of symbols, push the current symbol onto the stack. If the array has an odd number of elements and you are at the center, skip to the next iteration. If you are past the half-way mark, pop a test symbol off the stack. If the test doesn't match the symbol at the current position, the symbols aren't balanced so you can print out your message and quit. If you finish iterating over the array, then the String is balanced. Now you just need to translate this into Java ;)

Anonymous at Answerbag.com Visit the source

Was this solution helpful to you?

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.