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 add the 'Tablet' item to the radio group rgrpQ1_1, and set the color of rgrpQ1_1 to 'Cream', use the following code:

procedure AddDevice;
begin
  rgrpQ1_1.Items.Add('Tablet');
  rgrpQ1_1.Color := clCream;
  rgrpQ1_1.ItemIndex := 0;
end;

Step 2

Button [1.2 - Apply]

99%

104 rated

Answer

To implement the functionalities detailed in 1.2, do the following:

  1. Retrieve Age: Extract the age from the edit box edtQ1_2 and convert it to an integer:

    age := StrToInt(edtQ1_2.Text);
    
  2. Check Citizenship: Verify if the South African citizen checkbox is checked. If it’s not checked, show a message:

    if not chkSouthAfricanCitizen.Checked then
      ShowMessage('The applicant must be a South African citizen.');
    
  3. Age Validation: Test if age meets the criteria of being 16 or older:

    if age < 16 then begin
      YearToApply := CURRENT_YEAR + (16 - age);
      ShowMessage('The applicant is too young. Can apply in the year ' + IntToStr(YearToApply));
    end;
    
  4. Success Case: If both conditions are satisfied and age >= 16, set edtQ1_2 to 'SUCCESSFUL':

    if age >= 16 then
      edtQ1_2.Text := 'SUCCESSFUL';
    

Step 3

Button [1.3 - Fractions]

96%

101 rated

Answer

Initialize all variables:

var
  Total, Top, Bottom: integer;
  Term: real;
begin
  Total := 0;
  Top := 1;
  Bottom := 1;
  1. Create a loop to sum the value of Term until the condition is met:
while (Total <= 4) do begin
  Term := Top / Bottom;
  Total := Total + Term;
  Inc(Bottom);
end;
  1. Display the results:
redQ1_3.Text := FloatToStrF(Total, ffGeneral, 4, 4);
redQ1_4.Text := IntToStr(Bottom - 1);

Step 4

Button [1.4.1 - Count letter]

98%

120 rated

Answer

  1. Extract Letter and Sentence:

    var
      letter: char;
      sentence: string;
      count: integer = 0;
    begin
      letter := edtQ1_4_1.Text[1];
      sentence := edtQ1_4.Text;
    
  2. Count Occurrences: Loop to check each character in the sentence:

    for i := 1 to Length(sentence) do begin
      if UpCase(sentence[i]) = UpCase(letter) then
        Inc(count);
    end;
    
  3. Display Count: Show the result on the panel:

    pnlQ1_4_1.Caption := 'Number: ' + IntToStr(count);
    

Step 5

Button [1.4.2 - Longest word]

97%

117 rated

Answer

  1. Initialize Length Variables:

    var
      longestWord: string;
      maxLength: integer = 0;
    begin
    
  2. Loop Through Sentence: Split the sentence to identify individual words:

    sentence := edtQ1_4.Text + ' ';
    word := '';
    for i := 1 to Length(sentence) do begin
      if sentence[i] = ' ' then begin
        if Length(word) > maxLength then begin
          maxLength := Length(word);
          longestWord := word;
        end;
        word := '';
      end else
        word := word + sentence[i];
    end;
    
  3. Display Longest Word: Show the length:

    ShowMessage('Length of longest word: ' + IntToStr(maxLength));
    

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

;