Photo AI

Open the incomplete program in the Question 1 folder - NSC Information Technology - Question 1 - 2023 - Paper 1

Question icon

Question 1

Open-the-incomplete-program-in-the-Question-1-folder-NSC Information Technology-Question 1-2023-Paper 1.png

Open the incomplete program in the Question 1 folder. Enter your examination number as a comment in the first line of the Question1_U.pas file. Compile and execute t... show full transcript

Worked Solution & Example Answer:Open the incomplete program in the Question 1 folder - NSC Information Technology - Question 1 - 2023 - Paper 1

Step 1

Button [1.1 - Display name and age]

96%

114 rated

Answer

To complete this section, first retrieve the name from the edit box edtQ1_1 and store it in the variable sName. Next, extract the age entered or selected from the spin edit box spnQ1_1 and store this in the variable iAge. Finally, use an output dialogue box to display the name and age, ensuring that they are presented one below the other. The format should be:

ShowMessage('Name: ' + sName + #13 + 'Age: ' + IntToStr(iAge));

Step 2

Button [1.2 - Hockey teams]

99%

104 rated

Answer

In this section, first extract the number of learners from the edit box and convert it to an integer. Store this in a suitable variable, such as numLearners. Next, calculate the number of teams using the formula numTeams := numLearners DIV PLAYERS;, and find the number of reserves using numReserves := numLearners MOD PLAYERS;. Finally, convert the results to strings and display them:

memoQ1_2.Lines.Add('Number of teams: ' + IntToStr(numTeams));
memoQ1_2.Lines.Add('Number of reserves: ' + IntToStr(numReserves));

Step 3

Button [1.3 - Calculate]

96%

101 rated

Answer

For this calculation, implement the formula to determine d using the provided equation. You should extract rX and rY from the relevant edit boxes. The formula can be expressed as follows:

d := Sqrt(Power((rX - rY), 4));
editQ1_3.Text := FloatToStrF(d, ffFixed, 10, 3);

Step 4

Button [1.4 - Marathon results]

98%

120 rated

Answer

In the case statement, first define the variable iPosition to store the finishing position of the participant. Use the following structure to display the appropriate message:

case iPosition of
  1: lblQ1_4.Caption := 'You receive a gold medal';
  2, 3: lblQ1_4.Caption := 'You receive a silver medal';
  4..20: lblQ1_4.Caption := 'You receive a bronze medal';
else
  lblQ1_4.Caption := 'You receive a participation certificate';
end;

Step 5

Button [1.5 - Average mark]

97%

117 rated

Answer

To process the file, start by declaring a file variable fFile. Then, initialize variables for total count and other relevant data. Use a loop to read through the file until the end, count learners, and extract marks, and compute the average:

AssignFile(fFile, 'Details.txt');
Reset(fFile);
while not EOF(fFile) do begin
  ReadLn(fFile, line);
  // Process line to extract mark
  Inc(count);
  totalMarks := totalMarks + mark;
end;
CloseFile(fFile);
averageMark := totalMarks / count;
ShowMessage('Average Mark: ' + FloatToStr(averageMark));

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

;