Welcome to Lesson 21!

Announcements

  • Last Lab due tomorrow at midnight
    • Final Exam on Tuesday at 11:30am in this classroom
      • Only methods from the 3 Methodical assignments
      • Draw heavily from practice quiz 8
      • One program from the two options provided
    • Last in-person office hour today from 1:30-2:20pm
      • No late work accepted after this office hour - no exceptions!
      • No late work more than one week old
      • Get there early as it will be packed!


    Review Activity

    1. Given the following lines of code, write a loop to read in the file word by word:

    String word;

    int count = 0;

          File file = new File("in.txt");

    Scanner input = new Scanner(file);

    while(  ????                      ) {    

        word = ????;

        count++;

        System.out.println("Word " + count + ": " + word);

    }

    2. Given the following lines of code, write a loop to read in the file line by line:


    String line;

    int count = 0;

          File file = new File("in.txt");

    Scanner input = new Scanner(file);

    while(  ????                      ) {    

        line = ????;

        count++;

        System.out.println("Line " + count + ": " + line);

    }


    3. Declare an array of Strings called pets and assign it the values dog, cat, rabbit, bird in TWO DIFFERENT WAYS (static and non-static initialization)


    4. Print out the contents of the above array using a for loop.


    5. Write a method to print an array of Strings to the console, with each element separated on its own line. The method should be named printArray. It takes an array of Strings as a parameter. It returns nothing.


    Final Project Presentations

    ~ Good Luck Studying! ~