CS 55  Java Programming

Week 7

Agenda

  • Chapter 7 - Arrays

References

  1. The Java Tutorial - Arrays
  2. Cafe au Lait Java - Java Course Notes -  Arrays

Examples

  1. Fibonacci.java prints out the first several Fibonacci numbers
  2. Fibonacci2.java same program but with a GUI

Lab07

  1. Exercise 7.13  Write an applet that inputs 5 numbers, each of which is between 10 and 100, inclusive. As each number is read, display it only if it is not a duplicate of a number already read. Use the GUI techniques introduced in Chapter 6. Display the results in a JTextArea. Use JTextArea method setText to update the results after each value is input by the user.
    • classname: UniqueFinderApplet
    • Hint: See the MultipleApplet.java example on the Week 6 web page for an example of how to build a GUI.
  2. Exercise 7.15  Write an applet to simulate the rolling of two dice. The sum of the two values should then be calculated. Your program should roll the dice 36,000 times. Use an array to tally the number of times each possible sum appears. Display the results in a JTextArea in tabular format. The applet should use the GUI techniques introduced in Chapter 6. Provide a JButton to allow the user to reset the counts to zero and then roll the dice another 36,000 times.
    • classname: DiceRollerApplet

Test 2 Information

  • When: next week
  • Test 2 will concentrate on material in chapters 4 - 7.
  • Study Guide
  • You will be given some requirements and asked to write Java code that satisfies the requirements.
  • Open-book, open-notes, open computer; no teamwork, no solicitation for help
  • You will have about one hour and twenty minutes.
  • You are responsible for everything covered in class and in the assigned chapters of Deitel through the end of this week's class.
 < CS 55  > Home Email Last Modified October 11, 2004