Programming and Problem Solving with Java

(やまだぃちぅ) #1

96


Bright flash then silence
My expensive computer
Has gone to heaven
Your program should input three strings with five syllables and two strings of
seven syllables. Output every possible 5–7–5 permutation of these phrases. Do
not use the same phrase twice in any poem. See if you can create phrases that
make sense together in every permutation. Be sure to include appropriate com-
ments in your code, choose meaningful identifiers, and use indentation as
shown in the code in this chapter.
2.Write a program that simulates the children’s game called “My Grandmother’s
Trunk.” In this game, the players sit in a circle, and the first player names some-
thing that goes in the trunk: “In my grandmother’s trunk, I packed a pencil.” The
next player restates the sentence and adds something new to the trunk: “In my
grandmother’s trunk, I packed a pencil and a red ball.” Each player in turn adds
something to the trunk, attempting to keep track of all the items that are already
there.
Your program should simulate just five turns in the game. Starting with the
empty string, simulate each player’s turn by reading and concatenating a new
word or phrase to the existing string, and print the result.
3.Write a program that prints its own grading form. The program should output
the name and number of the class, the name and number of the programming
assignment, your name and student number, and labeled spaces for scores
reflecting correctness, quality of style, late deduction, and overall score. Have the
program input the name, ID number, and assignment number as strings. An ex-
ample of such a form is the following:
CS–101 Introduction to Programming and Problem Solving

Programming Assignment 1

Sally A. Student ID Number 431023877

Grade Summary:

Program Correctness: Quality of Style:
Late Deduction: Overall Score:
Comments:
Free download pdf