Practice

Double Entry Validation

2023/May/Jun·Variant 2·Q4(b)·[3 marks]
MEDIUMLoops

Implement a double-entry check for a measurement.

Ask the user to enter the measurement twice. If both entries match, store the value in Measurement and output Accepted. If they don't match, repeat the process until they do.

Source: Inspired by 2023 May/Jun Variant 2 Q4(b)(ii)

Input: Pairs of integers until both match. Each pair is two lines. Output: Accepted followed by the accepted value, each on a separate line.

Example:

Input:  10
        5       (mismatch — try again)
        10
        10      (match!)
Output: Accepted
        10
Premium is coming soon. All grading features are currently unlocked.

Sample Test Cases

Test 1: Match on first attempt
Inputs: 10, 10
Expected: Accepted 10
Test 2: Match on second attempt
Inputs: 5, 3, 5, 5
Expected: Accepted 5
Test 3: Zero value
Inputs: 0, 0
Expected: Accepted 0
Press Ctrl+Enter to run your code
or Ctrl+Shift+Enter to grade