The IT learners are writing programs to assist with the stocktaking process - NSC Information Technology - Question 5 - 2016 - Paper 2
Question 5
The IT learners are writing programs to assist with the stocktaking process.
5.1 A two-dimensional array called arrStock has been used to record the quantities of t... show full transcript
Worked Solution & Example Answer:The IT learners are writing programs to assist with the stocktaking process - NSC Information Technology - Question 5 - 2016 - Paper 2
Step 1
Write pseudocode to calculate the total stock per item and store these values in the array.
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
// Initialize total stock array
FOR row FROM 0 TO 3 DO
total[row] ← 0
// Loop through each department
FOR col FROM 0 TO 4 DO
total[row] ← total[row] + arrStock[row][col]
END FOR
// Store total in the last column of arrStock
arrStock[row][4] ← total[row]
END FOR
Step 2
Identify the type of error for each process in the table below.
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
(a) Syntax Error: This error occurs when there is a missing semicolon at the end of an instruction, leading to compilation issues.
(b) Logical Error: The stock value is calculated incorrectly which signifies logical miscalculations in the program logic.
(c) Runtime Error: The mismatch in the data types during execution results in this type of error.
Step 3
Name TWO aspects that must be taken into consideration when providing the arguments (actual parameters) in a call statement.
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The number of arguments (actual parameters) must match the number of formal parameters in the method definition.
The type of arguments (actual parameters) must match the type of formal parameters expected by the method.
Step 4
Complete the algorithm to read the text file and populate the arrays.
98%
120 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
1. Open the text file StockDetails.txt for reading
2. Counter ← 0
3. Loop until the end of the StockDetails.txt file
Read line from file
// Check if the line mentions a Tablet
IF line contains "Tablet" THEN
Extract room number from the line
Store room number in roomArray[counter]
Extract quantity issued and store in quantityArray[counter]
Increment counter
END IF
4. Close the file
Step 5
Give a possible reason why this message was displayed.
97%
117 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The error message 'File does not exist' may have been displayed because the path to the file was incorrectly specified, or the text file was not available in the working folder.
Step 6
Redraw and complete the trace table to determine the four numeric values in the arrNumbers array if number of values has a value of 4.
97%
121 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!