dogHears

Category: Programming
Author: Jessica Miller
Book Chapter: 5.1
Problem: dogHears
It is said that all dogs hear when people talk to them are their names (see cartoon by Gary Larson to the right). Write a static method named dogHears that prints lines of what a dog hears. The method accepts two parameters: a dog's name, as a string, and the number of lines, as an integer. Each line contains a randomly chosen number of words, between 2 - 10 words inclusive.

Each word on a given line is chosen randomly to be one of two choices: the dog's name, with 25% probability (1/4 likelihood); or the word "blah", with 75% probability (3/4 likelihood). This does not mean that the dogs name will print exactly every fourth time; just that a given word has a 1/4 random chance of being the dog's name. Multiple calls to dogHears with the same parameters will likely result in different output for each call.

If 0 or less is passed for the number of lines, no output should be produced.