Use the problem statement and I/O design to create a hierarchy chart.
Problem Statement:
Imagine that you and a number of friends go to a luxury restaurant, and when you ask for the bill you want to split the amount and the tip (15 percent) between all. Your program should print the amount of the bill, the tip, the total cost, and the amount each person has to pay. It should also print how much of what each person pays is for the bill and for the tip.
Output:
The calculated tip amount / tip
The total cost including the bill and the tip / totalCost
The amount each person has to pay / splitAmount
The amount each person pays for the bill / billPerPerson
The amount each person pays for the tip / tipPerPerson
A detailed breakdown of what each person pays / individualPayment
Input:
The total amount of the bill / billAmount
The number of people in the party / peopleCount
To create a hierarchy chart for the problem statement provided, we will break down the program into its main components and subcomponents. The hierarchy chart will illustrate the relationships between these components, showing how they interact to achieve the desired functionality.
Main Program
│
├── Input Module
│ ├── Get Bill Amount (billAmount)
│ └── Get Number of People (peopleCount)
│
├── Calculation Module
│ ├── Calculate Tip (tip)
│ │ └── Calculate Tip Amount (tipAmount)
│ ├── Calculate Total Cost (totalCost)
│ ├── Calculate Split Amount (splitAmount)
│ ├── Calculate Amount Per Person
│ │ ├── Calculate Bill Per Person (billPerPerson)
│ │ └── Calculate Tip Per Person (tipPerPerson)
│ └── Generate Individual Payment Breakdown (individualPayment)
│
└── Output Module
├── Print Tip Amount (tipAmount)
├── Print Total Cost (totalCost)
├── Print Split Amount (splitAmount)
├── Print Bill Per Person (billPerPerson)
├── Print Tip Per Person (tipPerPerson)
└── Print Individual Payment Breakdown (individualPayment)
Main Program: This is the entry point of the program that orchestrates the flow of execution.
Input Module:
Calculation Module:
Output Module:
This hierarchy chart provides a clear structure for the program, making it easier to understand the flow of data and the relationships between different