String quit zzz string bookgroupscountsize 1 to 5

This preview shows page 11 - 15 out of 500 pages.

string QUIT = “ZZZ” string BOOK_GROUPS[COUNT_SIZE] = “1 to 5 books”, “6 through 12 books”, “13 or more books” getReady() while name <> QUIT countBooks() endwhile finishUp() stop getReady() output “Enter the author’s name or ”, QUIT, “ to quit ” input name return countBooks() output “Enter the number of books written and target reader age ” input numBooks, age if (numBooks >= 1 AND numBooks <= MAX_BOOKS) AND (age >= 0 AND age <= MAX_AGE) then x = COUNT_SIZE – 1 while numBooks < BOOK_RANGES[x] x = x – 1 endwhile bookCnts[x] = bookCnts[x] + 1 else output “Invalid data, record not counted” endif output “Enter the author’s name or ”, QUIT, “ to quit ” input name return finishUp() x = 0 while x < COUNT_SIZE output BOOK_GROUPS[x], bookCnts[x] x = x + 1 endwhile return c. Modify the author registration program so that the output is a count of the number of bo Answer: A sample solution follows Flowchart:
Pseudocode: start Declarations num numBooks num age num x num MAX_BOOKS = 40 num MAX_AGE = 16 num COUNT_SIZE = 5 num ageCnts[COUNT_SIZE] = 0 num AGE_RANGES[COUNT_SIZE] = 0, 3, 8, 11, 14 string name string QUIT = “ZZZ” string AGE_GROUPS[COUNT_SIZE] = “under 3”, “3 through 7” “8 through 10”, “11 through 13”, “14 and older” getReady() while name <> QUIT countAges() endwhile finishUp() stop getReady() output “Enter the author’s name or ”, QUIT, “ to quit” input name return countAges() output “Enter the number of books written and target reader age ” input numBooks, age if (numBooks >= 1 AND numBooks <= MAX_BOOKS) AND (age >=0 AND age <= MAX_AGE) then x = COUNT_SIZE – 1 while age < AGE_RANGES[x] x = x – 1 endwhile ageCnts[x] = ageCnts[x] + numBooks else output “Invalid data, record not counted” endif output “Enter the author’s name or ”, QUIT, “ to quit” input name return finishUp() x = 0 while x < COUNT_SIZE
output AGE_GROUPS[x], ageCnts[x] x = x + 1 endwhile return 1 Yoga 1 2 Yoga 2 3 4 5 5. a. The Downdog Yoga Studio offers five types of classes, as shown in Table 6-2. Design a pr Class Number Class Name Childre n’s Yoga Prenata l Yoga Senior Yoga Table 6-2 Downdog Yoga Studio classes
return finishUp() output “End of program” return b. Modify the Downdog Yoga Studio program so that numeric class requests can be entered con

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture