Essay about Chapter 6 solutions

4152 Words May 21st, 2014 17 Pages
Programming Logic and Design, 6e

Solutions 6-1

Programming Logic and Design, 6th Edition
Chapter 6
Exercises
1.

a. Design the logic for a program that allows a user to enter 10 numbers, then displays them in the reverse order of their entry.

Answer:
A sample solution follows
Flowchart:

Pseudocode: start Declarations num index num SIZE = 10 num numbers[SIZE] = 0,0,0,0,0,0,0,0,0,0 getReady() Programming Logic and Design, 6e

Solutions 6-2

while index < SIZE getNumbers() endwhile finishUp() stop getReady() index = 0 return getNumbers() output “Enter a number for position ”, index input numbers[index] index = index + 1 return finishUp() output “The numbers in reverse order are: ” while index >
…show more content…
Answer: A sample solution follows
Flowchart:

Programming Logic and Design, 6e

Pseudocode: start Declarations num age num income num x string gender string maritalStatus num SIZE = 5 num ageCnt[SIZE] = 0

Solutions 6-32

Programming Logic and Design, 6e

Solutions 6-33

num AGE_RANGE[SIZE] = 0, 20, 30, 40, 50 string AGE_GROUPS[SIZE] = “under 20”, “20 through 29”,
“30 through 39”, “40 through 49”,
“50 and older” getReady() while not eof detailLoop() endwhile finishUp() stop getReady() output “Enter the age, gender, marital status, and income of a reader” input age, gender, maritalStatus, income return detailLoop() x = SIZE – 1 while age < AGE_RANGE[x] x = x – 1 endwhile ageCnt[x] = ageCnt[x] + 1 output “Enter the age, gender, marital status, and income of a reader” input age, gender, maritalStatus, income return finishUp() x = 0 while x < SIZE output AGE_GROUPS[x], ageCnt[x] x = x + 1 endwhile return

b. Modify the Daily Life Magazine program so that it produces a count of readers by gender within age group—that is, under 20 females, under 20 males, and so on.
Answer: A sample solution follows
Flowchart:

Programming Logic and Design, 6e

Pseudocode: start Declarations num age num income num x string gender string maritalStatus num SIZE = 5

Solutions 6-34

Programming Logic and Design, 6e

Solutions 6-35

num maleCnt[SIZE] = 0

Related Documents