5. a. Draw the hierarchy chart and then plan the logic for a program for the sales manager of
The Couch Potato Furniture Company. The manager needs a program to determine the profit on any item sold. Input includes the wholesale price and retail price for an item. The output is the item’s profit, which is the retail price minus the wholesale price. Use three modules. The main program declares global variables and calls housekeeping, detail, and end-of-job modules. The housekeeping module prompts for and accepts a wholesale price. The detail module prompts for and accepts the retail price, computes the profit, and displays the result.
The end-of-job module displays the message “Thanks for using this program”.
Answer: A sample solution is as follows:
Data Dictionary:
Input:
Variable Name wholesalePrice retailPrice
Description
Price paid by company
Price charged to customer Type
Numeric
Numeric
Output:
Variable Name
WHOLE_PROMPT
RETAIL_PROMPT profit END_LINE
Description
Message requesting wholesale price
Message requesting retail price
Retail price minus
Wholesale price
Message displayed after profit calculated Type
String
String
Value
“Enter the wholesale price.”
“Enter the retail price.” Numeric
String
“Thanks for using this program.”
Hierarchy chart:
main program
housekeeping()
Flowchart:
detail()
endOfJob()
Pseudocode: start Declarations num wholesalePrice num retailPrice num profit string WHOLE_PROMPT = “Enter the wholesale price” string RETAIL_PROMPT = “Enter the retail price” string END_LINE = “Thanks for using this program” housekeeping() detail() endOfJob() stop housekeeping() output WHOLE_PROMPT input wholesalePrice return detail() output RETAIL_PROMPT input retailPrice profit = retailPrice - wholesalePrice output profit return endOfJob() output END_LINE
return