A program that continuously accepts sign order data

This preview shows page 66 - 73 out of 96 pages.

We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
Invitation to Computer Science
The document you are viewing contains questions related to this textbook.
Chapter 6 / Exercise 10
Invitation to Computer Science
Gersting/Schneider
Expert Verified
b. A program that continuously accepts sign order data and displays all the relevant information for oak signs with five white letters.Answer: A sample solution is as follows:Flowchart:
We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
Invitation to Computer Science
The document you are viewing contains questions related to this textbook.
Chapter 6 / Exercise 10
Invitation to Computer Science
Gersting/Schneider
Expert Verified
Programming Logic and Design, 8eSolutions 4-67Pseudocode:startDeclarationsnum orderNumnum numCharsnum pricestring custNamestring woodTypestring colorCharsnum MIN_FEE = 30num GOLD_FEE = 12num OAK_FEE = 15num CHAR_LIMIT = 6num ADD_CHAR_FEE = 3housekeeping()while not eofdetailLoop()endwhilefinish()stop
Programming Logic and Design, 8eSolutions 4-68housekeeping()output “Sign program”input orderNum, custName, woodType, numChars, colorCharsreturndetailLoop()if woodType = “oak” AND numChars = 5 AND colorChars = “white” thenprice = MIN_FEE + OAK_FEEoutput orderNum, custName, woodType, numChars, colorChars, priceendifinput orderNum, custName, woodType, numChars, colorChars returnfinish()output “End of program”returnc. A program that continuously accepts sign order data and displays all the relevant information for pine signs with gold-leaf lettering and more than 10 characters.Answer: A sample solution is as follows:Flowchart:
Programming Logic and Design, 8eSolutions 4-69Pseudocode:startDeclarationsnum orderNumnum numCharsnum pricestring custNamestring woodTypestring colorCharsnum MIN_FEE = 30num GOLD_FEE = 12num OAK_FEE = 15num CHAR_LIMIT = 6num ADD_CHAR_FEE = 3housekeeping()while not eofdetailLoop()endwhile
Programming Logic and Design, 8eSolutions 4-70finish()stophousekeeping()output “Sign program”input orderNum, custName, woodType, numChars, colorCharsreturndetailLoop()if woodType = “pine” AND numChars > 10 AND colorChars = “gold” thenprice = MIN_FEE + GOLD_FEE + (numChars – CHAR_LIMIT) * ADD_CHAR_FEEoutput orderNum, custName, woodType, numChars, colorChars, priceendifinput orderNum, custName, woodType, numChars, colorChars returnfinish()output “End of program”return10. Black Dot Printing is attempting to organize carpools to save energy. Each input record contains an employee’s name and town of residence. Ten percent of the company’s employees live in Wonder Lake; 30 percent live in the adjacent town of Woodstock. BlackDot wants to encourage employees who live in either town to drive to work together. Design a flowchart or pseudocode for the following:a. A program that accepts an employee’s data and displays it with a message that indicates whether the employee is a candidate for the carpool (because he lives in one of the two cities).Answer: A sample solution is as follows:Flowchart:
Programming Logic and Design, 8eSolutions 4-71Pseudocode:startDeclarationsstring empNamestring empTownstring MESSAGE = “You can carpool!”housekeeping()detail()finish()stophousekeeping()output “Carpool program”input empName, empTownreturndetail()if empTown = “Wonder Lake” OR empTown = “Woodstock” thenoutput empName, empTown, MESSAGEendifreturnfinish()output “End of program”returnb. A program that continuously accepts employee data until a sentinel value is entered,
Programming Logic and Design, 8eSolutions 4-72

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture