Computer Science – Algorithm design and problem-solving | e-Consult
Algorithm design and problem-solving (1 questions)
Flowchart
A flowchart would visually represent the steps in the program. It would include:
- Start/End symbols
- Input/Output symbols (for prompting and displaying information)
- Process symbols (for calculations)
- A decision symbol (to handle the loop for multiple items)
The flowchart would show the sequence of events: start, get number of items, loop through items, get price for each item, calculate total, display total, end.
Structure Diagram
A structure diagram would show the program's main components and how they interact. It would likely include:
- A main program process
- A loop process (to handle multiple items)
- Input processes (for getting the number of items and prices)
- Output process (for displaying the total cost)
The diagram would illustrate the flow of data between these components.
Pseudo-code
START
INPUT num_items
total_cost = 0
FOR i = 1 TO num_items
INPUT item_price
totalcost = totalcost + item_price
END FOR
OUTPUT "The total cost is: " + total_cost
END