How can I present a solution using pseudocode and a flowchart? Identify the logic needed to apply a discount on all items in the shopping cart. Verify that the logic captures the discount and...

How can I present a solution using pseudocode and a flowchart?

  • Identify the logic needed to apply a discount on all items in the shopping cart.
  • Verify that the logic captures the discount and the list of items from the user.
  • Use the loop to visit all items in the shopping cart, and adjust their prices based on the discount value.
  • Utilize loop structures in the solution.
Expert Answers
Karen P.L. Hardison eNotes educator| Certified Educator

While we don't have the tools (or the aim) of drawing the pseudocode flowchart for you, we can help talk you through how to go about satisfying the requirements of this computer programming task.

Starting with the programming flowchart, a programming flowchart combines predefined geometric symbols and arrowed lines with simple pseudocode sentences to describe a problem, a solution and an action (or a process) to be carried out by a computer program operation.

Processing operations might show the logical steps in carrying out the solution of the task in a straight linear relationship (one end solution), called "sequencing"; in a "Yes" "No" alternative relationship (two possible end solutions), called "decision"; or in a repeating relationship (multiple applications of a process(s)), called "looping." Each operation relationship has specific guidelines for using pseudocode and for building the flowchart.


The logic for applying a monetary discount to all items an online customer has placed in a website shopping cart is looping logic: the process will be applied--will be looped--over and over again to each individual item in the shopping cart. The logic is not "decision" because, since the discount is applied to all items, the end result isn't derived from a "Yes" "No" alternative resulting in two possible processing routes (although "Yes" "No" decision logic may be incorporated as a part of the looping process). The logic is not "sequence" because there is not one single process that arrives at one, final end solution. The logic statements would include the problem, the discussion, the output, input and processing. For a discount applied to a whole shopping cart, the logic would be similar to this:

  • Problem: Apply a discount to each item in an entire shopping cart of items.
  • Discussion: The discount equals 10% of the price of each item.
  • Output: The discounted price per item.
  • Input: The Item prices.
  • Process: Find the price of each item; deduct the 10% discount from each price; find the final item price.


The pseudocode language, simplified program descriptive sentences, would describe a loop and capture the logic in a manner similar to this:

  • Determine the discounted price of each item in a shopping cart
  • Initialize multiplier and deduct from price
  • Do While there are more data
  •   a. Get next item
  •   b. Multiply by discount
  •   c. Finalize discounted price
  • Loop
  • Final Item Price


The flowchart would graphically represent the programming process and be labeled with the pseudocode. Some significant elements of the flowchart include these:

  • The flowchart begins and ends with the geometric shape of a sideways oval. The top one will be labeled Start (or Begin) while the bottom one will be labeled End.
  • A directional arrow will indicate the flow of the program between one step and the next. With a loop involved, some directional arrows will point the side and some back toward the top (indicating a loop), although the primary sequential arrows will point downward.
  • On the step during which the next item price is retrieved, the sequencing will incorporate pseudocode asking something similar to: "Are there more items?" At this step, a decision sequence will be incorporated with "Yes" looping to the next item price and "No" diverting the program to the end result and to the End oval shape.
  • On the "Yes" diversion, the loop is initiated and is indicated by a directional arrow to the left, joined by another toward the top, joined by another to the right that ends at the primary sequence arrow just ahead of the diamond shape asking "Are there more items?"

Pseudocode and flowcharts are clearly explained in a PowerPoint made available by the Computer Science Department of Suffolk County Community College (SCCC) in Long Island, New York, with clear examples provided; this answer is drawn from the SCCC PowerPoint.