Past-paper question · 2018 October-November · Paper 32 · Q5(a)

Question 5(a) 2018 · October-November · Paper 32 · 8 marks

Original past-paper question for 5(A)
Original past-paper question for 5(A)
Reveal official mark-scheme answer Official mark-scheme answer for 5(A)

Official answer for Question 5

Part (a)

✓
Eight from:

Question 8

✓
Checking each line of code/statement
✓
Ensures that each line of code is executed at least once
✓
Ensures that var y and z assign the collected numbers as required
✓
Checks that the additon of y and z is correct
✓
Ensures that the correct message is displayed when result assigned to A
✓
Checking each branch/decision in the code
✓
Checks that decisions are carried out correctly
✓
So that values put in A can be compared
✓
Ensures that result is checked against > 10
✓
Ensures that the correct result is put in var × as required
✓
Checks every possible pathway through the code
✓
So that test values in var y and z cause each subsequent path to be
✓
followed
✓
So that test values in x are assigned to A to produce both the messages “is
✓
greater than 10” and “is not greater than 10” depending on value in A.

Mark scheme 9626_w18_ms_32.pdf →

Show text version of question

Question 5

Part (a)

Question 5

Quintin is a programmer who writes code in HTML and JavaScript for use in online forms. The

code is developed and ‘white-box’ tested before being used.

Quintin is developing the code below. He has added comments to the code. The code asks a user to input two numbers and adds the numbers together. It also displays the total and whether or not it is greater than 10.

<html> <body>

<!-- the next six lines collect the two numbers to be added-->

<br/>Enter first number: <input type="number" id="nm1" name="num1"> <br/><br/>Enter second number: <input type="number" id="nm2" name="num2"> <p id="add"></p>

<script> function myaddfunction() { //the next line assigns the first number input to the variable y var y = document.getElementById("nm1").value; //the next line assigns the second number input to the variable z var z = document.getElementById("nm2").value; //the next line adds the two numbers and assigns the result to the variable x var x = +y + +z; //the next line checks if x is greater or not greater than 10 and reports accordingly var A = (x >10) ? x+ " is greater than 10":x+ " is not greater than 10"; //the next line prints the results onto the page document.getElementById("add").innerHTML = A ; } </script> <!-- the next two lines asks the user to click the button and then the script is executed <p>Click the button to calculate the total.</p> <button onclick="myaddfunction()">Add the numbers</button> <br/> </body> </html>

Question 9

Part (a)

Explain how Quintin could use ‘white box’ testing to ensure that the JavaScript code produces

the correct result every time.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[8]

Question 10

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_w18_qp_32.pdf

Keep practising this topic