CS 5JA, Winter 2009
Assignment 3 - Programming simple decisions and loops

This project is based on exercises in the text. To the extent that instructions here differ from those in the text, the instructions on these web pages take precedence.

Due: Tuesday, February 10, 9:00 pm
Worth: 100 homework points

  1. Write the two applications specified in Exercises 4.21 and 4.23 on pp. 152-153 of the text.
    1. First write Largest.java to solve Exercise 4.21.
      • See the instructions and hints in the text. In particular, it is strongly recommended that you develop the algorithm before typing in the program - the text refers to this step as writing "a pseudocode program" - but you will just turn in the Java source.
      • Use a java.util.Scanner object to get the 10 integers from the user.
      • Match these sample Largest runs from our solution. Notice (in the second run) that all 10 numbers might be less than zero.
    2. Then write TwoLargest.java to solve Exercise 4.23.
      • You might want to start with a copy of Largest.java, as this problem is just an extension of the first one.
      • Again see the instructions in the text (including the note).
      • Match these sample TwoLargest runs from our solution. Notice (in the second run) that the largest and second largest values might equal one another.
  2. Complete the graphical application specified in the "GUI and Graphics Case Study" Exercise 4.1 on pp. 143-144 of the text. Begin with this skeleton of CornerLines.java and test your drawings by compiling and executing CornerLinesTest.java.
    1. First do part a of the exercise - see the text - even though you will not turn in this early version of CornerLines.java (assuming you complete part b too). Mimic the techniques used to draw lines in the text's class DrawPanel (Fig. 4.19, p. 142), and try to match this preliminary drawing from our solution.
    2. Then modify the drawing as directed in part b of the exercise. Match this final drawing from our solution.
  3. Turn in Largest.java, TwoLargest.java and CornerLines.java here before the deadline.

Updated 1/25/09, by C. Michael Costanzo