0% found this document useful (0 votes)
25 views3 pages

2d Array Assignment

Uploaded by

tawana nyika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views3 pages

2d Array Assignment

Uploaded by

tawana nyika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

2D array

Assignment
1
5 A firm employs workers who assemble amplifiers. Each member of staff works an agreed number
of hours each day.

The firm records the number of completed amplifiers made by each employee each day.

Management monitor the performance of all its workers.

Production data was collected for 3 workers over 4 days.

Daily hours
worked Production data
Worker 1 5 Worker 1 Worker 2 Worker 3
Worker 2 10 Day 1 10 20 9

Worker 3 10 Day 2 11 16 11

Day 3 10 24 13

Day 4 14 20 17

A program is to be written to process the production data.

(a) The production data is to be stored in a 2-dimensional array ProductionData, declared as


follows:

(i) Write code to declare the array ProductionData

............................................................................................................................ ............
[2]
...........................................................................................................................................

Describe two features of an array.

1 ........................................................................................................................................

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

2 ........................................................................................................................................

.......................................................................................................................................[2]

(ii) Give the value of ProductionData[3, 2].

.......................................................................................................................................[1]

(iii) Describe the information produced by the expression:

ProductionData[2, 1] + ProductionData[2, 2] + ProductionData[2, 3]

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

.......................................................................................................................................[2]

© UCLES 2015 9608/23/M/J/15


(b) Complete the trace table for the pseudocode algorithm below.

FOR WorkerNum 1 TO 3
WorkerTotal[WorkerNum] 0
ENDFOR

FOR WorkerNum 1 TO 3
FOR DayNum 1 TO 4
WorkerTotal[WorkerNum] WorkerTotal[WorkerNum] +
ProductionData[DayNum, WorkerNum]
ENDFOR
ENDFOR

FOR WorkerNum 1 TO 3
WorkerAverage WorkerTotal[WorkerNum]/
(4 * DailyHoursWorked[WorkerNum])
IF WorkerAverage < 2
THEN
OUTPUT “Investigate“, WorkerNum
ENDIF
ENDFOR

WorkerTotal
WorkerNum DayNum WorkerAverage OUTPUT 1 2 3

[8]

© UCLES 2015 9608/23/M/J/15 [Turn over

You might also like