Answer a sample solution follows flowchart 30

This preview shows page 30 - 36 out of 50 pages.

Answer: A sample solution followsFlowchart:30
Programming Logic and Design, 7eSolutions 8-Pseudocode:startDeclarationsstring namestring msgnum age31
Programming Logic and Design, 7eSolutions 8-num ageIndexnum HOLES = 9num GROUPS = 5num scores[HOLES]num AGE_RANGE[GROUPS] = 4, 5, 8, 12, 16num PARS[GROUPS][HOLES] = {8, 8, 9, 7, 5, 7, 8, 5, 8},{7, 7, 8, 6, 5, 6, 7, 5, 6},{6, 5, 6, 5, 4, 5, 5, 4, 5},{5, 4, 4, 4, 3, 4, 3, 3, 4},{4, 3, 3, 3, 2, 3, 2, 3, 3}num x = 0num scoreTotal = 0num parTotal = 0getReady()fillArray()displayScores()stopgetReady()output “Enter the player’s name and age”input name, agereturnfillArray()x = 0while x < HOLESoutput “Enter score for hole ”, x+1input score[x]scoreTotal = scoreTotal + score[x]x = x + 1endwhilereturndisplayScores()output namedetermineAgeIndex()x = 0while x < HOLESparTotal = parTotal + PARS[ageIndex][x]if score[x] >= PARS[ageIndex][x] thenif score[x] = PARS[ageIndex][x] thenmsg = “Par”elsemsg = “Over par”endifelsemsg = “Under par”endifoutput score[x], msgx = x + 1endwhileoutput “Total score = ”, scoreTotaloutput “Strokes from par = ”, scoreTotal - parTotalreturn32
Programming Logic and Design, 7eSolutions 8-determineAgeIndex()x = GROUPS – 1while age < AGE_RANGE[x]x = x – 1endwhileageIndex = xreturn10.Building Block Day Care Center charges varying weekly rates depending on the age of the child and the number of days per week the child attends, as shown in Table 8-7. Develop the logic for a program that continuously accepts child care data and displays the appropriate weekly rate.Days Per WeekAge in Years12345030.0060.0088.00115.00140.00126.0052.0070.0096.00120.00222.0046.0067.0089.00110.00322.0040.0060.0075.0088.004 or more20.0035.0050.0066.0084.00Answer: A sample solution followsFlowchart:33
Programming Logic and Design, 7eSolutions 8-Pseudocode:startDeclarationsnum agenum daysnum ageIndexnum ratenum AIY = 5num DPW = 5num RATES[AIY][DPW] = {30, 60, 88, 115, 140},34
Programming Logic and Design, 7eSolutions 8-{26, 52, 70, 96, 120},{24, 46, 67, 89, 110},{22, 40, 60, 75, 88},{20, 35, 50, 66, 84}num QUIT = 999getReady()while age <> QUITdetermineRate()endwhilefinishUp()stopgetReady()output “Enter the age or ”, QUIT, “ to quit”input agereturndetermineRate()output “Enter the number of days per week”input daysif age > 4 thenageIndex = 4elseageIndex = ageendifrate = RATES[ageIndex][days-1]output “Weekly rate is: ”, rateoutput “Enter the age or ”, QUIT, “ to quit”input agereturnfinishUp()output “End of program”return11.Executive Training School offers typing classes. Each final exam evaluates a student’s typing speed and the number of typing errors made. Develop the logic for a program that produces a summary table of each examination’s results. Each row represents the number of students whose typing speed falls within the following ranges of words per minute: 0–19, 20–39, 40–69, and 70 or more. Each column represents the number of students who made different numbers of typing errors—0 through 6 or more.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture