Photo AI

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

Question icon

Question 1

Open-the-incomplete-program-in-the-Question-1-folder-NSC Information Technology-Question 1-2022-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 - 2022 - Paper 1

Step 1

Button [1.1 - Add device]

96%

114 rated

Answer

To implement the required functionality for the radio group rpgQ1_1, you need to add a new item. The code for this can be structured as follows:

procedure TForm1.Button1Click(Sender: TObject);
begin
  rpgQ1_1.Items.Add('Tablet');
  rpgQ1_1.Color := clCream;
  rpgQ1_1.ItemIndex := 0;
end;

Step 2

Button [1.2 - Apply]

99%

104 rated

Answer

You will retrieve the age and handle the conditions for citizenship and age eligibility as follows:

procedure TForm1.Button2Click(Sender: TObject);
var
  age: Integer;
  yearToApply: Integer;
begin
  age := StrToInt(edtQ1_2.Text);

  if not chkSouthAfrican.Checked then
    ShowMessage('The applicant must be a South African citizen')
  else
  begin
    if age < 16 then
    begin
      yearToApply := CURRENT_YEAR + (16 - age);
      ShowMessage('The applicant is too young.' + sLineBreak + 'Can apply in the year ' + IntToStr(yearToApply));
    end
    else
      ShowMessage('SUCCESSFUL');
  end;
end;

Step 3

Button [1.3 - Fractions]

96%

101 rated

Answer

For this part, ensure that you're capturing the sentence and performing your calculations accordingly:

procedure TForm1.Button3Click(Sender: TObject);
var
  Total, Top, Bottom, Term: Double;
begin
  Total := 0;
  Top := 1;
  Bottom := 1;

  while Total <= 4 do
  begin
    Term := Top / Bottom;
    Total := Total + Term;
    Inc(Bottom);
  end;

  redQ1_3.Text := FormatFloat('0.0000', Total);
  redQ1_3.Text := IntToStr(Bottom - 1);
end;

Step 4

Button [1.4.1 - Count letter]

98%

120 rated

Answer

To count the occurrences of a specific letter in the sentence:

procedure TForm1.Button4Click(Sender: TObject);
var
  letter: Char;
  count, i: Integer;
  sentence: string;
begin
  letter := edtQ1_4_1.Text[1];
  count := 0;
  sentence := LowerCase(edtQ1_4.Text);

  for i := 1 to Length(sentence) do
    if sentence[i] = LowerCase(letter) then
      Inc(count);

  pnlQ1_4_1.Caption := IntToStr(count);
end;

Step 5

Button [1.4.2 - Longest word]

97%

117 rated

Answer

To find the longest word, the following structured approach can be adopted:

procedure TForm1.Button5Click(Sender: TObject);
var
  words: TStringList;
  longestWord: string;
begin
  words := TStringList.Create;
  try
    words.Text := StringReplace(edtQ1_4.Text, ' ', sLineBreak, [rfReplaceAll]);
    longestWord := '';

    for i := 0 to words.Count - 1 do
      if Length(words[i]) > Length(longestWord) then
        longestWord := words[i];

    ShowMessage('Length of longest word: ' + IntToStr(Length(longestWord)));
  finally
    words.Free;
  end;
end;

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

;