Past-paper question · 2018 February-March · Paper 32 · Q6

Question 6 2018 · February-March · Paper 32 · 8 marks

Original past-paper question for 6
Reveal official mark-scheme answer Official mark-scheme answer for 6

Official answer for Question 6

✓
Eight from:

Question 8

✓
Suitable code would be:
✓
var AgeNow, CanApply;
✓
AgeNow = Number(document.getElementById("AgeNow").value);
✓
if (isNaN(AgeNow)) {
✓
CanApply = "Please enter your age in numbers.";
✓
} else {
✓
CanApply = (AgeNow < 16)? "You are too young to apply for a
✓
licence.": "You are old enough to apply for a licence.";
✓
Mark points: 8 from:
✓
Declare the variables, must be exact variable names as in Question:
✓
var AgeNow, CanApply;
✓
Capture the input of the age:
✓
AgeNow=Number()
✓
Use of correct capture code:
✓
document.getElementById("AgeNow").value;
✓
Use of “isNaN” to check that the input is a number:
✓
if (isNaN(AgeNow))
✓
Display error message if not a number:
✓
CanApply = "Please enter your age in numbers.";
✓
Use of “if...else” to make decision:
✓
} else {
✓
Use of comparison check: CanApply = (AgeNow < 16)?
✓
Appropriate display messages: e.g. "You are too young to apply for a
✓
licence.": "You are old enough to apply for a licence.";
✓
Messages match comparison: i.e.:
✓
< 16... too young; old enough
✓
>16.... old enough; too young
✓
9626/32
✓
Cambridge International AS/A Level – Mark Scheme
✓
March 2018
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9626_m18_ms_32.pdf →

Show text version of question

Question 6

Drivers who are 16 years of age or older can apply for a driving licence online. The government web page code requires applicants to enter their age and then checks if they are old enough to apply. The following code captures the applicant’s age. When the applicant clicks the ‘Check now’ button the age is first checked to ensure that it is numeric. The age is then checked to see if the applicant is old enough. Suitable messages are displayed as a result of the checks. Complete the code for the function CheckAgeFunction that checks the age entered by the applicant and displays an appropriate response. <html> <body> <p>You can apply for a licence to drive when you are 16 years old.</p> <p>To check if you are old enough to drive, input your age and click the button:</p> <input id="AgeNow" value="16" /> <button onclick="CheckAgeFunction()">Check now</button> <p id="AgeCheck"></p> <script> function CheckAgeFunction() { .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... ......................................................................................................................................................[8] } document.getElementById("AgeCheck").innerHTML = CanApply; } </script> </body></html>

Question 12

Topic relevance

Why this question appears here

98% assigned-topic match · Programming for the web

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9626_m18_qp_32.pdf

Keep practising this topic