Answer a sample solution follows flowchart pseudocode

This preview shows page 19 - 23 out of 396 pages.

14. Ellison Private Elementary School has three classrooms in each of nine grades, kindergarten
num K_TUITION = 80num TUITION_FACTOR = 60housekeepingdetailLoop()finishUp()stophousekeeping()grade = 0returndetailLoop()while grade <= MAX_GRADEif grade = 0 thentuition = K_TUITIONelsetuition = grade * TUITION_FACTORendifroom = 1while room <= MAX_ROOMmonth = 1while month <= MAX_MONTHoutput grade, room, month, tuitionmonth = month + 1endwhileroom = room + 1endwhilegrade = grade + 1endwhilereturnfinishUp()output “End of program”return15. a. Design a program for the Hollywood Movie Rating Guide, in which users continuously en
num count = 0num total = 0num avgstring PROMPT = “Enter the star rating or anegative number to quit >> ”housekeeping()while numOfStars >= 0detailLoop()endwhilefinishUp()stophousekeeping()output PROMPTinput numOfStarsreturndetailLoop()while numOfStars > 4 OR numOfStars < 0output “Please re-enter a value from 0 to 4 >> ”input numOfStarsendwhilecount = count + 1total = total + numOfStarsoutput PROMPTinput numOfStarsreturnfinishUp()avg = total / countoutput “The average star rating is: ”, avgoutput “End of program”returnb. Modify the movie-rating program so that a user gets three tries to enter a valid rating. After thFlowchart:Pseudocode:startDeclarationsnum numOfStarsnum count = 0Answer:A sample solution follows
num total = 0num attemptsnum avgnum LIMIT = 3string PROMPT = “Enter the star rating or anegative number to quit >> ”housekeeping()while numOfStars >= 0 AND attempts < LIMITdetailLoop()endwhilefinishUp()stophousekeeping()output PROMPTinput numOfStarsattempts = 0returndetailLoop()while (numOfStars > 4 OR numOfStars < 0) AND attempts < LIMIToutput “Please re-enter a value from 0 to 4 >> ”input numOfStarsattempts = attempts + 1endwhileif attempts < LIMIT thencount = count + 1total = total + numOfStarsoutput PROMPTinput numOfStarselseoutput “You have failed to enter a valid rating.”output “The program will now end.”endifreturnfinishUp()if attempts < LIMIT thenavg = total / countoutput “The average star rating is: ”, avgendifoutput “End of program”return

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 396 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
Joan Mast
Tags
NUM, sentinel value, Domicile Designs, Hunterville College

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture