Countclasses if classnum 1 and classnum size then

This preview shows page 14 - 19 out of 500 pages.

countClasses() if classNum >= 1 AND classNum <= SIZE then classCnt[classNum-1] = classCnt[classNum-1] + 1 else output “Invalid class number” endif output “Enter a class number or ”, QUIT, “ to quit” input classNum return finishUp() classNum = 0
while classNum < SIZE output classNum+1, classes[classNum], classCnt[classNum] classNum = classNum + 1 endwhile return Answer: Flowchart: Pseudocode: start Declarations num stuID num classNum num score num SIZE = 30 num QUIT = 9999 num totalPnts[SIZE] = 0 getReady() while stuID <> QUIT collectStudentData() endwhile finishUp() stop getReady() output “Enter a student ID or ”, QUIT, “ to quit” input stuID return collectStudentData() output “Enter the classroom number and score for student ”, stuID input classNum, score if classNum >= 1 AND classNum <= SIZE then totalPnts[classNum - 1] = totalPnts[classNum - 1] + score else output “Invalid classroom number” endif output “Enter a student ID or ”, QUIT, “ to quit” input stuID return 6. a. Watson Elementary School contains 30 classrooms numbered 1 through 30. Each classroo A sample solution follows
finishUp() classNum = 0 while classNum < SIZE output classNum + 1, totalPnts[classNum] classNum = classNum + 1 endwhile return b. Modify the Watson Elementary School program so that each classroom’s average of the test s Answer: A sample solution follows Flowchart: Pseudocode: start Declarations num stuID num classNum num score num avg num SIZE = 30 num QUIT = 9999 num totalPnts[SIZE] = 0 num classCnts[SIZE] = 0 getReady() while stuID <> QUIT collectStudentData() endwhile classNum = 0 finishUp() stop getReady() output “Enter a student ID or ”, QUIT, “ to quit” input stuID return collectStudentData() output “Enter the classroom number and score for student ”, stuID input classNum, score if classNum >= 1 AND classNum <= SIZE then totalPnts[classNum - 1] = totalPnts[classNum - 1] + score classCnts[classNum - 1] = classCnts[classNum - 1] + 1 else output “Invalid classroom number”
endif output “Enter a student ID or ”, QUIT, “ to quit” input stuID return finishUp() classNum = 0 while classNum < SIZE if classCnts[classNum] = 0 then avg = 0 else avg =totalPnts[classNum]/classCnts[classNum] endif classNum = classNum + 1 endwhile return Product Price ($) 0.89 0.25 0.59 1.5 1.75 Answer: A sample solution follows Flowchart: Pseudocode: start Declarations string itemOrdered num x output classNum + 1, avg 7. The Jumpin’ Jive coffee shop charges $2.00 for a cup of coffee, and offers the add-ins show Whipped cream Cinnamo n Chocola te sauce Amarett o Irish whiskey Table 6-3 Add-in list for Jumpin’ Jive coffee shop Design the logic for an application that allows a user to enter ordered add-ins continuously until
num found = 0 num total = 2 num SIZE = 5 string QUIT = “ZZZZ” num PRICES[SIZE] = 0.89, 0.25, 0.59, 1.50, 1.75 string PRODUCTS[SIZE] = “Whipped cream”, “Cinnamon”, “Chocolate sauce”, “Amaretto”, “Irish whiskey” string ERROR_MSG = “Sorry, we do not carry that” getReady() while itemOrdered <> QUIT detailLoop() endwhile finishUp() stop getReady() output “Enter an item or ”, QUIT, “ to complete your order” input itemOrdered return detailLoop() found = 0 x = 0

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture