Photo AI

Margaret needs to keep track of how much money she makes - Edexcel - GCSE Computer Science - Question 4 - 2019 - Paper 1

Question icon

Question 4

Margaret-needs-to-keep-track-of-how-much-money-she-makes-Edexcel-GCSE Computer Science-Question 4-2019-Paper 1.png

Margaret needs to keep track of how much money she makes. She collects the sales figures on a weekly basis. (a) The pseudocode of an algorithm is shown. w = 0 ... show full transcript

Worked Solution & Example Answer:Margaret needs to keep track of how much money she makes - Edexcel - GCSE Computer Science - Question 4 - 2019 - Paper 1

Step 1

Discuss the suitability of this code for humans

96%

114 rated

Answer

The provided pseudocode has several limitations that make it unsuitable for humans to read and understand. The main issues include:

  1. Lack of Clarity: The pseudocode uses variable names like 'w' without any description or meaning. This makes it difficult for humans to understand what 'w' represents in the context of the algorithm.

  2. Informal Structure: The structure of the pseudocode lacks clarity. For example, there are no comments or explanations of what each step does, which would assist in understanding the flow of the algorithm.

  3. Non-Descriptive Commands: The command 'SEND w TO DISPLAY' is vague and does not explain what display means. Details on where or how w is being displayed are essential for understanding.

  4. Infinite Loop Possibility: The condition 'UNTIL w = 52' may lead to misunderstandings. Without context, a reader might not realize the significance of 52, which presumably represents the number of weeks in a year. This context is necessary for effective understanding.

Step 2

How it could be improved

99%

104 rated

Answer

To improve the pseudocode for better human readability, the following changes could be made:

  1. Meaningful Variable Names: Replace 'w' with a more descriptive name such as 'weekCount' to indicate the purpose of the variable.

    weekCount = 0
    
  2. Add Comments: Include comments to clarify the purpose of each section of the code. This helps to explain the intention behind the code to the reader.

    // Initialize week counter
    weekCount = 0
    // Repeat until we have displayed all weeks
    REPEAT
        weekCount = weekCount + 1
        SEND weekCount TO DISPLAY // Display the current week count
    UNTIL weekCount = 52
    
  3. Clearly Define Actions: Define what 'DISPLAY' means. Providing a more explicit description of how and where the week count is displayed will aid understanding.

  4. Use of Indentation: Proper indentation can help in visually representing the structure of the pseudocode, making it easier to follow the logic. For instance, the repeat block can be visually separated from the rest of the code.

Join the GCSE students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;