Programming and Problem Solving with Java

(やまだぃちぅ) #1

38


Identify the obvious objects in the instructions. Then identify which portions of
this algorithm consist of a sequence of instructions, where branches occur,
where loops occur, and where subprograms are called.
3.Music notation works much like a programming language. Identify the symbols
and notation in music that indicate a unit of music in a sequence of such units,
that indicate repetition of a section of music, that indicate a choice between
endings of a song, and that indicate a separate section to be played or sung at a
given point. If you aren’t familiar with musical notation, you’ll need to do some
research in books on basic musicianship.
4.Browse through the next several chapters of this book and identify Java
statements that are used for branching and looping. (Hint:Look in the table of
contents.)

Programming Problems


1.Write an algorithm for driving from where you live to the nearest airport that
has regularly scheduled flights. Restrict yourself to a vocabulary of 20 words plus
numbers and place names. You must select the appropriate set of words for this
task. The purpose of this exercise is to give you practice in writing simple, exact
instructions with a small vocabulary, just as a computer programming language
requires you to do.
2.Write an algorithm for making a peanut butter and jelly sandwich, using a
vocabulary of just 20 words (you choose the words). Assume that all ingredients
are available in the cabinet or refrigerator and that the necessary tools are in a
drawer under the kitchen counter. The instructions must be very simple and ex-
act because the person making the sandwich has no knowledge of food prepara-
tion and takes every word literally.
3.Write an algorithm for doing your laundry, using a vocabulary of just 20 words
(you choose the words). Assume that you have the detergent, bleach, fabric
softener, and any other objects needed to do the laundry, and that the starting
state is you standing before a washing machine with your laundry and these ob-
jects. The ending state is a set of clean, neatly folded laundry items (no starch in
the socks, please).

Case Study Follow-Up


1.Expand the instructions for Sally’s responsibility to make the shopping list. It
may help to imagine that you are writing the instructions for someone else to
follow.
2.You have another friend who plays guitar and sings. How might you change the
plan for the party and reassign the responsibilities?
Free download pdf