Chris Pollett>Old Classes>CS102, Spring 1999>Hw4

CS 102
HW#4

        Due by 4pm, Thursday, March 18, 1999. Read Chapter 14 in Deitel and read to page 184 in Bailey. Then make a subdirectory of your homepage directory called hw4 (make sure you have the case right). The command to do this is cd public_html<ret> mkdir hw4 <ret>. Put your source code for this homework here. Leave the modifications on your homework so that no one can read or execute it until you want to submit the homework. When you decided to submit move into your public_html directory and type chmod -R a+rx hw4<ret>. Then under your browser find the class page and click on the homework bot to get it to collect your homework. After doing this, again in your public_html directory, type: chmod 0700 hw4 <ret>.

  1. Write an applet that has a textarea and an gif icon of your choosing. If a user enters a string involving only open and close parentheses and click on the icon then the applet prints "balanced" or "unbalanced" depending on whether the parenthesization was balanced or not. For instance, "(bob)((()()))" is balanced. "(" and "(()golf" are not. Use stacks to implement the parentheses checking. An applet with a text field and a button that says click me. When pressed checks if text field well-parenthesized.
  2. Do problem 7.6 in Bailey. Put your answer in a file reverse.txt
  3. Write an applet with an editable textarea, noneditable textarea, and a submit button. Use a GridBagLayout to arrange these components. When submit is clicked this applet copies the data from the textarea word-by-word into separate elements in a Vector. By a word I mean a string of non-blank characters. Using a filtering iterator the applet outputs in the other textarea all words that follow either the word "sale" or the word "discount". You will need to download the code for Iterator.java and myVector.java.