Syllabus: Grading, Policies, Office Hours
Calendar of Events: topics & homework

Homework #2: A Square of z's
50 points, due 10/26/2000 at the beginning of class for all sections.

Create an Java applet that will draw a square of z's in the Applet window as big as the user wants. There should be a Message Dialog box that tells the user what the program will do. See below for an example.

There should then be an Input Dialog box that asks the user how long each side of the square should be.

The program should then draw a square (note: a square by definition has the same length for height and width) of z's in the applet window with the desired number of z's on each side. It should also state how many z's were drawn in the status bar at the bottom of the window. Do not overlap the z's.

Helpful hints:

  1. Think of the user when designing the Dialog Boxes: is it obvious to the user what he/she is supposed to do?
  2. This is an applet, not an application. The two methods headers you will be using will be init and paint.
  3. To print a "z" in the applet window, you would use a drawString statement in the paint method body.
  4. To print text in the status bar (at the bottom of the applet window), use the showStatus method. The showStatus method can be contain Strings and variable values, just like println, JOptionPane, and drawString can. In the paint method body, use a statement like this:
  5. showStatus ( "My age is " + years );

  6. Use proper style conventions in your source code. This includes indentation styles. Be sure that your source code does not run off the right side of the printout.
  7. You will need to use nested loops (preferably for loops) to get the grid to be displayed.

Turn in a printout of your source code and a diskette with the Java file on it. Name the Java program with your last name and first initial and the number "2". EX: BookA2.java (note: I'm VERY picky about the name of the file, including capitalization.) Be sure that your diskette is labeled with your name.

Grading criteria:

1. does it compile & run? 22
2. correct processing of the information, and correct information displayed in the applet window 15
3. user-friendliness: well-designed dialog boxes 5
4. program source code is commented, logically laid out, and follows style conventions 5
5. files properly labeled 3
TOTAL POINTS POSSIBLE: 50
   

syllabus | calendar (day) | calendar (evening) | grades
DSMIS Dept. | SLU School of Business | Saint Louis University
 
all rights reserved. copyright 2000, Ann Book.