15-100 Lecture 9 (Monday, September 19, 2005)

Quick Quiz

  // Write the specification for a class, Quiz
  class Quiz {

    /*
     * Assume that, magically, and without you writing it, this class contains
     * the following method:
     *
     *  public static int promptUserForInt(String prompt);
     */

    // Within the main method, please do the following:
    public static void main (String[] args) throws Exception {
      // 1) Use promptUserForInt(String prompt) to get two numbers from 
         //    the user
      int number1 = promptUserForInt ("Enter the first number: ");
      int number2 = promptUserForInt ("Enter the second number: ");

     if (number1 == number2) {
       // 2) If the two numbers are equal, print, "The numbers ARE equal."
       System.out.println ("The numbers ARE equal.");
     } else {
       // 3) Otherwise print, "The two numbers are NOT equal"
       System.out.println ("The numbers are NOT equal.");
     }
    }
  }
  

Review Day

Today turned out to be mostly a reinforcement day. We spent most of the class reinforcing old material, including and especially the use of methods. We spoke about the "signature" of a method, including its name and argument list. The correspondence between the arguments passed at the time a method is called and the arguments within the "formal argument list" provided by the method's definition, &c.

This material was all reinforcement and is captured in other notes.