Draw the hierarchy chart and design the logic for a program that contains housekeeping

Draw the hierarchy chart and design the logic for a program that contains housekeeping, detail loop, and end-of-job modules, and that calculates the service charge customers owe for writing a bad check. The main program declares any needed global variables and constants and calls the other modules. The housekeeping module displays a prompt for and accepts a customer’s last name. While the user does not enter “ZZZZ” for the name, the detail loop accepts the amount of the check in dollars and cents. The service charge is computed as $20 plus 2 percent of the check amount. The detail loop also displays the service charge and then prompts the user for the next customer’s name. The end-of-job module, which executes after the user enters the sentinel value for the name, displays a message that indicates the program is complete.

The Correct Answer and Explanation is:.


Problem Summary:

  • The program calculates service charges for customers who write bad checks.
  • Main program declares global variables/constants and calls three modules: Housekeeping, Detail Loop, and End-of-Job.
  • Housekeeping Module: Displays prompt and accepts customer’s last name.
  • Detail Loop Module: While name ≠ “ZZZZ”, accepts check amount, computes service charge = \$20 + 2% of check amount, displays service charge, then prompts for next customer name.
  • End-of-Job Module: After sentinel “ZZZZ” is entered, displays completion message.

Hierarchy Chart

Main Program
├── Housekeeping Module
├── Detail Loop Module
└── End-of-Job Module
  • Main Program controls overall flow.
  • Housekeeping gets the initial customer name.
  • Detail Loop processes customers repeatedly until sentinel.
  • End-of-Job finishes the program.

Logic Design (Pseudocode)

Main Program
    Declare customerName as String
    Declare checkAmount as Float
    Declare serviceCharge as Float
    Declare constant BASE_CHARGE = 20.00
    Declare constant PERCENT_CHARGE = 0.02

    Call Housekeeping Module (to get first customerName)

    While customerName != "ZZZZ"
        Call Detail Loop Module (pass customerName, get checkAmount)
        Calculate serviceCharge = BASE_CHARGE + (PERCENT_CHARGE * checkAmount)
        Display serviceCharge
        Call Housekeeping Module (get next customerName)
    End While

    Call End-of-Job Module
End Main Program


Housekeeping Module
    Prompt "Enter customer's last name (enter ZZZZ to quit): "
    Input customerName
    Return customerName
End Housekeeping Module


Detail Loop Module (customerName)
    Prompt "Enter amount of bad check for " + customerName + ": $"
    Input checkAmount
    Return checkAmount
End Detail Loop Module


End-of-Job Module
    Display "Program complete. Thank you."
End End-of-Job Module

This program is structured into three main modules under the control of a main program, enabling clear separation of concerns and modular programming principles.

1. Main Program:
The main program declares the global variables and constants needed throughout the program, including customerName, checkAmount, and serviceCharge, as well as constants for the base service charge and percentage charge. It initiates the process by calling the housekeeping module to receive the first customer’s last name.

2. Housekeeping Module:
This module is responsible for input handling of the customer’s last name. It displays a prompt asking the user to enter the last name or “ZZZZ” to indicate no more customers. This input controls whether the program will proceed with calculations or terminate. Returning the customer name to the main program keeps input encapsulated and easily maintainable.

3. Detail Loop Module:
The detail loop is the core processing unit. For each customer, it requests the amount of the bad check. Then, the program calculates the service charge based on the formula: a flat \$20 fee plus 2% of the check amount. This fee calculation ensures customers are charged fairly based on the check amount but with a minimum service fee. The service charge is displayed immediately after calculation. Once this is done, the program again calls the housekeeping module to accept the next customer name, thereby forming a loop that continues until the sentinel value “ZZZZ” is entered.

4. End-of-Job Module:
After exiting the loop (when “ZZZZ” is input), the end-of-job module provides a clean ending to the program by displaying a message indicating that processing is complete. This finalizes user interaction and improves program usability.

Modularization allows each part of the program to be developed, tested, and maintained independently. The hierarchy chart clearly illustrates the control flow, with the main program calling each module in sequence and looping through the detail loop as long as necessary. This approach improves clarity, reduces redundancy, and aligns with best practices in software design.


Scroll to Top