AQA GCSE Computer Science Paper 1 (1A), June 2025: Question 4

13 marks · Medium difficulty · Programming

Validate user input using string length checks, write a C# validation routine with iteration, identify types and examples of test data, and complete a username generation flowchart.

Practise this question

Question

Question 04 contains multiple parts about input validation and testing: 04.1 asks for the purpose of validation via multiple-choice; 04.2 asks students to write a C# program to validate a user's first name to be longer than 1 character and fewer than 15 characters, looping until valid; 04.3 is a multiple-choice question defining boundary test data; 04.4 and 04.5 present a test plan table (Figure 3) asking for the number of characters for a boundary test resulting in rejection, and the missing test data type; 04.6 gives pseudo-code lines labelled L1 to L6 in Figure 4 for username generation, asking to complete a flowchart.
Question text

04 A programmer is developing a system to register users for an app. The program

needs to validate the first name of the user.

04.1 Identify the purpose of validation.

Shade one lozenge.

[1 mark]

A Checks that the user is human

B Checks that the user is who they say they are

C Checks that the input is a name

D Checks that the input is reasonable

04.2 Write a C# program to check the user’s first name.

Your program should:

• get the user’s first name

• check that the first name has more than one character and fewer than 15

characters:

o if it has, output the message Name accepted

o if it has not, output the message Name not accepted

• repeat until the name entered has a specified length.

You should use meaningful variable name(s) and C# syntax in your answer.

The answer grid below contains vertical lines to help you indent your code.

[6 marks]

04.3 Which of the following statements best describes boundary test data?

*08*Shade one lozenge.

[1 mark]

A Data that is not of the allowed data type

B Data that is at the limits of the allowed range

C Data that is expected by the program

D Data that will cause a syntax error

04.4 The programmer has started planning the tests that will be used to check the program

is working correctly.

The program should:

• check that the first name has more than one character and fewer than

15 characters:

o if it has, then output the message Name accepted

o if it has not, then output the message Name not accepted

The start of the test plan is shown in Figure 3.

Figure 3

Test Type of

Test data Expected result

number test data

1 Thomas Normal Name accepted

2 Boundary Name not accepted

State the number of characters that a string used for test number 2 in Figure 3 could

contain.

[1 mark]

04.5 Normal and boundary are two types of test data.

State one type of test data that has not been used in Figure 3.

[1 mark]

04.6 A programmer is designing an algorithm to generate usernames for users.

The algorithm should:

• ask the user to input their first name and their last name

*10*•create a username:

o if their first name has more than three characters, their username will consist of

the first three characters of their first name followed by their last name

o if their first name has three or fewer characters, their username will consist of

their full first name followed by their last name

• output the username.

Figure 4 contains the statements required to implement a version of this algorithm.

Figure 4

firstName USERINPUT

LEN(firstName) > 3

username firstName + lastName

OUTPUT username

username SUBSTRING(0, 2, firstName) + lastName

lastName USERINPUT

Using the labels ( to ) shown in Figure 4, complete the flowchart to implement

the algorithm.

[3 marks]

Mark scheme

Show the mark scheme Mark scheme for Question 04: 04.1 awards 1 mark for D (Checks that the input is reasonable). 04.2 provides a 6-mark breakdown (1 for design, 5 for program logic including iteration, length check, combined conditions, re-inputting, and appropriate outputs) with sample code solutions in C#, Python, and VB.NET. 04.3 awards 1 mark for B (Data that is at the limits of the allowed range). 04.4 awards 1 mark for 1 or 15. 04.5 awards 1 mark for Erroneous. 04.6 gives the completed flowchart assigning L1, L6 to inputs, L2 to the decision diamond, L3 to the 'N' branch, L5 to the 'Y' branch, and L4 to the output parallelogram for 3 marks.

Total

Question Part Marking guidance

marks

04 1 Mark is for AO1 (recall) 1

D Checks that the input is reasonable;

R. If more than one lozenge shaded

Total

Question Part Marking guidance

marks

04 2 1 mark for AO3 (design), 5 marks for AO3 (program) 6

Program Design

Note that AO3 (design) marks are for selecting appropriate techniques to

use to solve the problem, so should be credited whether the syntax of

programming language statements is correct or not and regardless of

whether the solution works.

Mark A for the use of an iteration structure that exists within their language,

which attempts to repeat until a first name with a valid length is entered;

Program Logic

Mark B for finding the length of at least one string correctly;

Mark C for one Boolean condition that attempts to check the first name or

length of first name entered against one of the two required conditions (even

if the length usage is incorrectly coded or missing);

A. if the only error is quotes included around numeric values;

Mark D if all required checks on the length of the first name have been

carried out and combined correctly;

R. if any quotes included around numeric values

Mark E for code that allows the re-inputting of a first name within an iteration

structure;

Mark F for a structure that would output either Name accepted or Name

not accepted correctly in all circumstances; A. if conditions are

not fully correct; A. equivalent messages;

I. Case

I. Messages or no messages with input statements

I. Gaps/spaces throughout the code, except where to do so would explicitly

alter the logic of the code in a way that makes it incorrect.

Maximum 5 marks if any errors in code.

Note to examiners

In C#/VB.NET examples, explicit variable declarations are not shown. Refer

to the specific language type issues section of the appropriate Marking

Guidance document. Any correct variable declarations in student answers

should be accepted.MARK SCHEME – – –

C# Example 1 (fully correct)

The design mark is achieved (Mark A)

name = Console.ReadLine();

while (name.Length < 2 || name.Length > 14) { BCD, Part E

Console.WriteLine("Name not accepted"); Part F

name = Console.ReadLine(); Part E

}

Console.WriteLine("Name accepted"); Part F

A. Write in place of WriteLine

I. missing Console.

Python Example 1 (fully correct)

The design mark is achieved (Mark A)

name = input()

while len(name) < 2 or len(name) > 14: BCD, Part E

print("Name not accepted") Part F

name = input() Part E

print("Name accepted") Part F

Python Example 2 (fully correct)

The design mark is achieved (Mark A)

check = False Part E

while check == False: Part E

name = input() Part E

if len(name) > 1 and len(name) < 15: BCD

print("Name accepted") Part F

check = True

else:

print("Name not accepted") Part F

Python Example 3 (fully correct)

The design mark is achieved.

Check that all pathways are covered when using nested if statements and

all required messages are included.

while True: Part E

name = input()

if len(name) > 1: BC

if len(name) < 15: D

print("Name accepted") Part F

break

else:

print("Name not accepted") Part F

else:

print("Name not accepted") Part F

VB.NET Example 3 (fully correct)

The design mark is achieved.

Check that all pathways are covered when using nested if statements and

all required messages are included.

While True Part E

name = Console.ReadLine()

If Len(name) > 1 Then BC

If Len(name) < 15 Then D

Console.WriteLine("Name accepted") Part F

Exit While

Else

Console.WriteLine("Name not accepted") Part F

End If

Else

Console.WriteLine("Name not accepted") Part F

End If

End While

A. Write in place of WriteLine;

I. missing Console.

Total

Question Part Marking guidance

marks

04 3 Mark is for AO1 (recall) 1

B Data that is at the limits of the allowed range;

R. If more than one lozenge shaded

Total

Question Part Marking guidance

marks

04 4 Mark is for AO3 (test) 1

1 // 15;

A. if both correct answers are given;

Total

Question Part Marking guidance

marks

04 5 Mark is for AO1 (recall) 1

Erroneous;

A. Invalid;

A. Description of a type of erroneous test data e.g. data of the wrong type;

I. Minor spelling mistakes

R. Typical

R. Extreme

R. Boundary

R. Normal

Total

Question Part Marking guidance

marks

04 6 3 marks for AO3 (design) 3

MP1: for L1, L6 (I. Order of L1 and L6) and L4;

MP2: for L2;

MP3: for L3 and L5;

I. any pseudocode if labels are given

A. The exact given pseudo-code statements if labels are omitted;

How to answer it

Input Validation, Test Plans & Flowchart Algorithms

📋 What This Question Tests

This multi-part exam question assesses foundational computational thinking and programming skills:

  • Validation vs. Authentication: Recalling the formal definition and purpose of defensive input validation.
  • Iterative Validation Loops (C#): Constructing a pre-condition or post-condition loop that tests string length boundaries and re-prompts the user until valid data is entered.
  • Testing Terminology & Boundary Data: Identifying boundary/limit values that fall just outside valid ranges (> 1 and < 15).
  • Algorithm Flowcharts: Mapping assignment, conditional branching, string concatenation, and output statements into standard flowchart logic.
Question 04.1 (1 Mark)

Purpose of Validation

Identify the purpose of validation

✅ Correct Answer

D: Checks that the input is reasonable

❌ Common Errors & Distractors

  • Option A & B: Checking if a user is human (e.g. CAPTCHA) or confirming identity is authentication, not validation.
  • Option C: Validation cannot tell if a string is a "real" name; it can only confirm it meets preset reasonable rules (e.g., correct length or type).
Mark Scheme: 1 mark for AO1 (Recall). Awarded strictly for option D. Reject if more than one lozenge is shaded.
Question 04.2 (6 Marks)

C# Validation Routine with Length Check

Write a C# program to check that a user's first name has > 1 and < 15 characters

✅ Model Solution (C#)

string name = Console.ReadLine(); while (name.Length <= 1 || name.Length >= 15) { Console.WriteLine("Name not accepted"); name = Console.ReadLine(); } Console.WriteLine("Name accepted");

📐 Logic Breakdown (Step-by-Step)

  1. Initial Input: Read the first string before entering the loop.
  2. Condition Negation: The prompt says valid is > 1 AND < 15 (lengths 2 to 14). Therefore, the loop repeats while the input is invalid: name.Length < 2 || name.Length > 14.
  3. Rejection Message & Re-prompt: Inside the loop, output "Name not accepted" and re-read the variable.
  4. Acceptance Output: Once the condition fails (valid input entered), loop terminates and prints "Name accepted" .

💡 Alternative Valid Approach (Boolean Flag)

bool valid = false; while (!valid) { string name = Console.ReadLine(); if (name.Length > 1 && name.Length < 15) { Console.WriteLine("Name accepted"); valid = true; } else { Console.WriteLine("Name not accepted"); } }

🧠 Exam Technique & Mark Breakdown

  • Mark A (AO3 Design): Iteration structure that attempts to repeat until valid input is given.
  • Mark B: Determining string length correctly ( .Length or len() ).
  • Mark C: Checking at least one relational condition against 1 or 15.
  • Mark D: Combining both conditions correctly with logical operators ( || or && ). Do not put quotes around numerical bounds!
  • Mark E: Allowing re-input inside the loop.
  • Mark F: Correct outputs for both accepted and rejected branches.
Examiner Insight: Maximum 5 marks if any syntax errors are present. A common error is writing while (name.Length > 1 && name.Length < 15) which would loop only when the input is valid!
Question 04.3 (1 Mark)

Definition of Boundary Test Data

Which statement best describes boundary test data?

✅ Correct Answer

B: Data that is at the limits of the allowed range

❌ Common Errors

  • Option A describes erroneous / invalid data.
  • Option C describes normal test data.
  • Option D describes code that fails compilation/interpretation, not test data categories.
Mark Scheme: 1 mark for AO1 (Recall). Reject if multiple answers selected.
Question 04.4 & 04.5 (2 Marks Total)

Test Plan Boundary Values & Data Types

04.4 Correct Value (1 Mark)

1 OR 15

The rule allows: greater than 1 AND fewer than 15 (acceptable character counts are 2 to 14).
A boundary value that gives "Name not accepted" must be immediately outside the valid limit: 1 or 15.

04.5 Missing Test Data Type (1 Mark)

Erroneous (or Invalid)

Normal and boundary are already listed in Figure 3. The remaining core category of test data is erroneous data (data that breaks data type or format rules).

❌ Pitfalls to Avoid

  • For 04.4: Do NOT write 0 or 16. While invalid, they are not boundary values. Do not write 2 or 14 because their expected result would be Name accepted !
  • For 04.5: Do NOT write "Extreme". The mark scheme explicitly rejects "Extreme" and "Typical" since AQA uses Normal, Boundary, and Erroneous.

🧠 Boundary Value Rule Summary

Length Category Result
1Boundary (Invalid)Not accepted ✅
2Boundary (Valid)Accepted
14Boundary (Valid)Accepted
15Boundary (Invalid)Not accepted ✅
Question 04.6 (3 Marks)

Flowchart Algorithm: Username Generator

Place labels L1 to L6 into the correct positions in the flowchart

✅ Correct Flowchart Label Placements

START
↓
Parallelogram 1: L1 (or L6)
↓
Parallelogram 2: L6 (or L1)
↓
Diamond Decision: L2
[ Yes / Y ] ↓
Rectangle: L5
[ No / N ] ↓
Rectangle: L3
↓
Parallelogram (Output): L4
↓
STOP

💡 Statement Reference Key

  • L1: firstName ← USERINPUT (Input)
  • L6: lastName ← USERINPUT (Input)
  • L2: LEN(firstName) > 3 (Decision condition)
  • L5: username ← SUBSTRING(0, 2, firstName) + lastName (Action if > 3 characters)
  • L3: username ← firstName + lastName (Action if ≤ 3 characters)
  • L4: OUTPUT username (Output)

🧠 How Marks Are Awarded

  • MP1: Inputs L1 and L6 in top input boxes (either order) AND L4 in the output parallelogram.
  • MP2: L2 in the decision diamond.
  • MP3: L5 on the 'Yes' / 'Y' path and L3 on the 'No' / 'N' path.
Examiner Insight: Pay close attention to flowchart shapes! Parallelograms are always for input/output (L1, L6, L4). Diamonds are always decisions (L2). Rectangles are always processes/assignments (L3, L5). Notice that "Yes" leads to the substring process (L5) because the question specifies first 3 characters when length > 3.

Topics

3.1 Fundamentals of algorithms · 3.2 Programming · 3.1.1 Representing algorithms · 3.2.2 Programming concepts · 3.2.7 Input/output · 3.2.8 String handling operations in a programming language · 3.2.11 Robust and secure programming

Question and mark scheme from the AQA GCSE Computer Science examination, Paper 1 (1A), June 2025. QuestionVault is an independent revision resource; questions remain the copyright of the awarding body.