CS 145 Lab 7 – Loops
Welcome to lab 7!
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 the following problems.
- In class
Vocab
, useScanner
andFile
to read this file of vocabulary scores as measured by the General Social Survey from 1972 to 2004. Treat the file as plain text. Read and parse it one line at a time. Compute and display the mean score for both males and females. - In class
WordNeighbors
, useScanner
andFile
to process a book of your choosing from Project Gutenberg. Identify a word of interest to you, like alien. Walk through the file one token at a time. Wherever the token contains your word, 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!