In some languages it’s easy to do if you are testing it as you go. In other languages it’s much more difficult.
For example, in Python you could do:
userInput = input(“Enter a number: “)
lenCheck = True
numCheck = True
if len(userInput) != 11:
lenCheck = False
for letter in userInput:
if not letter.isdigit():
numCheck = False
if not numCheck:
print(“There were non-numerical digits entered”)
elif not lenCheck:
print(“The length of a phonenumber must be 11 digits”)
(I’m guessing the indents won’t print properly, but you can get the idea).
I think it’s far too difficult a question for pupils to write out the answer. If they were given a computer and Internet access, that would be fair.
Like you, I can’t wait to see the solution. I can’t envisage there being a ‘one size fits all’ answer that pupils could genuinely be expected to provide. Then again, I’m often wrong 🙂