Photo AI

The IT learners are writing programs to assist with the stocktaking process - NSC Information Technology - Question 5 - 2016 - Paper 2

Question icon

Question 5

The-IT-learners-are-writing-programs-to-assist-with-the-stocktaking-process-NSC Information Technology-Question 5-2016-Paper 2.png

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

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

Answer

  1. (a) Syntax Error: This error occurs when there is a missing semicolon at the end of an instruction, leading to compilation issues.

  2. (b) Logical Error: The stock value is calculated incorrectly which signifies logical miscalculations in the program logic.

  3. (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

Answer

  1. The number of arguments (actual parameters) must match the number of formal parameters in the method definition.
  2. 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

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

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

Answer

number of valuesjloop counterkj modulus 2 = 0?arrNumbers[loop counter]
4101No5
2118No12
1428Yes4
04320No24

Join the NSC students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;