# teaching machines

## CS 148: Lab 8 – Loops

Welcome to lab 8!

If you have checkpoints from the last lab to show your instructor or TA, do so immediately. No credit will be given if you have not already completed the work, nor will credit be given after the first 10 minutes of this lab.

In this lab, we’ll explore loops, which let us execute a task many times, but only code it once.

### Checkpoint 1

Person A types. Log in to Coding Bat and solve the following problems:

### Checkpoint 2

Person B types. Create a package lab07 in your Eclipse project. Solve at least two of the following problems.

• In class Frame, prompt the user for a rectangular frame’s width, height, and border width. Print a frame composed of * for the border and . for the framed content. For example:
Width? 7
Height? 9
Border? 2
*******
*******
**...**
**...**
**...**
**...**
**...**
*******
*******
• In class Vocab, use Scanner and File to read this file of vocabulary scores as measured by the General Social Survey from 1972 to 2004. Compute and display the mean score for both males and females.
• In class WordNeighbors, use Scanner and File to process a book of your choosing from Project Gutenberg. Identify a word of interest to you, like alien. Wherever you encounter this word—or a word that contains it—in the book, print the word with its predecessor and successor words. For simplicity, consider punctuation as part of a word. For example:
an alien ate
favorite alien is
by aliens. Mom!