Structure Charts (Cambridge (CIE) A Level Computer Science): Revision Note

Exam code: 9618

Robert Hampton

Written by: Robert Hampton

Reviewed by: James Woodhouse

Updated on

Structure charts

What is a structure chart?

  • A structure chart is a modelling tool used in the design stage of program development

  • It helps to decompose a problem into smaller, manageable sub-tasks, representing each as a module

  • Structure charts focus on what the program does, not how it does it

Example

  • A program that asks a user to enter their username and password

  • Checks if the password matches the stored password and uses a counter to track how many times it is checked

  • If the password matches, a successful message is displayed, else after three failed attempts a 'denied' message is displayed

  • A structure chart might look like:

Flowchart of login process: input username, enter password, check password with conditions, possible outputs are "Login successful" or "Access denied".

Key features

Feature

Explanation

Top-down design

The chart starts with the main program and breaks it into sub-modules

Decomposition

Each module represents a specific task or function

Module boxes

Each module is shown as a box

Vertical lines

Show control flow – which module calls which

Parameter arrows

Arrows pointing into modules show data being passed in or returned

Stepwise refinement

Each level adds more detail to the task above

Diamond shape

Shows a condition that could be true or false

Semi-circular arrow

Indicates repetition

Pseudocode from structure chart

  • The first step is to create an identifier table

Identifier

Data type

Description

Username

STRING

Stores the username entered by the user

Password

STRING

Stores the password entered by the user

StoredPass

STRING

The correct password stored in the system for comparison

NoAttempts

INTEGER

Counts the number of failed login attempts

LoginSuccess

BOOLEAN

Indicates whether the login was successful

  • Next, identify is any functions or procedures could be used

Module

Type

Purpose

GetCredentials

PROCEDURE

Asks the user to input username and password

CheckPassword

FUNCTION

Compares input password with stored password and returns TRUE/FALSE

ShowAccessMessage

PROCEDURE

Displays success or failure message

  • Any finally, write the pseudocode

DECLARE Username : STRING
DECLARE Password : STRING
DECLARE StoredPass : STRING
DECLARE NoAttempts : INTEGER
DECLARE LoginSuccess : BOOLEAN

StoredPass ← "admin123"
NoAttempts ← 0
LoginSuccess ← FALSE

PROCEDURE GetCredentials()
    OUTPUT "Enter username: "
    INPUT Username
    OUTPUT "Enter password: "
    INPUT Password
ENDPROCEDURE

FUNCTION CheckPassword(P : STRING) RETURNS BOOLEAN
    IF P = StoredPass THEN
        RETURN TRUE
    ELSE
        RETURN FALSE
    ENDIF
ENDFUNCTION

PROCEDURE ShowAccessMessage(Success : BOOLEAN)
    IF Success = TRUE THEN
        OUTPUT "Login successful"
    ELSE
        OUTPUT "Access denied"
    ENDIF
ENDPROCEDURE

WHILE NoAttempts < 3 AND LoginSuccess = FALSE
    CALL GetCredentials()
    LoginSuccess ← CheckPassword(Password)

    IF LoginSuccess = FALSE THEN
        OUTPUT "Incorrect password"
        NoAttempts ← NoAttempts + 1
    ENDIF
ENDWHILE

CALL ShowAccessMessage(LoginSuccess)

You've read 0 of your 5 free revision notes this week

Unlock more, it's free!

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Did this page help you?

Robert Hampton

Author: Robert Hampton

Expertise: Computer Science Content Creator

Rob has over 16 years' experience teaching Computer Science and ICT at KS3 & GCSE levels. Rob has demonstrated strong leadership as Head of Department since 2012 and previously supported teacher development as a Specialist Leader of Education, empowering departments to excel in Computer Science. Beyond his tech expertise, Robert embraces the virtual world as an avid gamer, conquering digital battlefields when he's not coding.

James Woodhouse

Reviewer: James Woodhouse

Expertise: Computer Science & English Subject Lead

James graduated from the University of Sunderland with a degree in ICT and Computing education. He has over 14 years of experience both teaching and leading in Computer Science, specialising in teaching GCSE and A-level. James has held various leadership roles, including Head of Computer Science and coordinator positions for Key Stage 3 and Key Stage 4. James has a keen interest in networking security and technologies aimed at preventing security breaches.