fee SMALLFEE else if dogWeight MEDWGHT then fee MEDFEE else if dogWeight

Fee smallfee else if dogweight medwght then fee

• Homework Help
• 96
• 96% (282) 272 out of 282 people found this document helpful

This preview shows page 60 - 67 out of 96 pages.

fee = SMALL_FEE else if dogWeight <= MED_WGHT then fee = MED_FEE else if dogWeight <= LARGE_WGHT then fee = LARGE_FEE else fee = XLARGE_FEE endif endif endif if fee > 100 then output idNumber, dogName, dogBreed, dogAge, dogWeight, fee endif output PROMPT input idNumber return finish() output “End of program” return
Programming Logic and Design, 8e Solutions 4-61 d. A program that continuously accepts dogs’ data until a sentinel value is entered, and displays billing data for dogs who weigh less than 20 pounds or more than 100 pounds. Answer : A sample solution is as follows: Flowchart:
Programming Logic and Design, 8e Solutions 4-62
Programming Logic and Design, 8e Solutions 4-63 Pseudocode: start Declarations num idNumber num dogAge num dogWeight num fee string dogName string dogBreed num SMALL_FEE = 55 num MED_FEE = 75 num LARGE_FEE = 105 num XLARGE_FEE = 125 num SMALL_WGHT = 15 num MED_WGHT = 30 num LARGE_WGHT = 80 num QUIT = 9999 string PROMPT = “Enter an ID number or 9999 to quit >> ” housekeeping() while idNumber <> QUIT detailLoop() endwhile finish() stop housekeeping() output PROMPT input idNumber return detailLoop() input dogName, dogBreed, dogAge, dogWeight if dogWeight < SMALL_WGHT then fee = SMALL_FEE else if dogWeight <= MED_WGHT then fee = MED_FEE else if dogWeight <= LARGE_WGHT then fee = LARGE_FEE else fee = XLARGE_FEE endif endif endif if dogWeight < 20 OR dogWeight > 100 then output idNumber, dogName, dogBreed, dogAge, dogWeight, fee endif output PROMPT input idNumber return finish() output “End of program” return
Programming Logic and Design, 8e Solutions 4-64 9. Mark Daniels is a carpenter who creates personalized house signs. He wants an application to compute the price of any sign a customer orders, based on the following factors: The minimum charge for all signs is \$30. If the sign is made of oak, add \$15. No charge is added for pine. The first six letters or numbers are included in the minimum charge; there is a \$3 charge for each additional character. Black or white characters are included in the minimum charge; there is an additional \$12 charge for gold-leaf lettering. Design a flowchart or pseudocode for following: a. A program that accepts data for an order number, customer name, wood type, number of characters, and color of characters. Display all the entered data and the final price for the sign. Answer : A sample solution is as follows: Flowchart:
Programming Logic and Design, 8e Solutions 4-65 Pseudocode:
Programming Logic and Design, 8e Solutions 4-66 start Declarations num orderNum num numChars num price string custName string woodType string colorChars num MIN_FEE = 30 num GOLD_FEE = 12 num OAK_FEE = 15 num CHAR_LIMIT = 6 num ADD_CHAR_FEE = 3 housekeeping() detail() finish() stop housekeeping() output “Sign program” input orderNum, custName, woodType, numChars, colorChars return detail() price = MIN_FEE if woodType = “oak” then price = price + OAK_FEE endif if numChars > CHAR_LIMIT then price = price + (numChars – CHAR_LIMIT) * ADD_CHAR_FEE endif if colorChars = “gold” then price = price + GOLD_FEE endif output orderNum, custName, woodType, numChars, colorChars, price return finish() output “End of program” return b. A program that continuously accepts sign order data and displays all the relevant