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
Related Q & A:
- If you were to start using a Wordpress framework today, which one would you use?Best solution by WordPress
- Is it correct to extend a bean class and write a class which holds logic to populate the bean we extend?Best solution by stackoverflow.com
- How to write a program to monitor the temperature of CPU?Best solution by Stack Overflow
- How to write a TV program proposal?
- What is a good program to use to design your own magazine?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.