Photo AI

SECTION A QUESTION 1: GENERAL PROGRAMMING SKILLS Do the following: Open the incomplete project file called Question1_P.dpr in the Question 1 folder - NSC Information Technology - Question 1 - 2020 - Paper 1

Question icon

Question 1

SECTION-A--QUESTION-1:-GENERAL-PROGRAMMING-SKILLS--Do-the-following:--Open-the-incomplete-project-file-called-Question1_P.dpr-in-the-Question-1-folder-NSC Information Technology-Question 1-2020-Paper 1.png

SECTION A QUESTION 1: GENERAL PROGRAMMING SKILLS Do the following: Open the incomplete project file called Question1_P.dpr in the Question 1 folder. Enter your ex... show full transcript

Worked Solution & Example Answer:SECTION A QUESTION 1: GENERAL PROGRAMMING SKILLS Do the following: Open the incomplete project file called Question1_P.dpr in the Question 1 folder - NSC Information Technology - Question 1 - 2020 - Paper 1

Step 1

Button [1.1 - Colours]

96%

114 rated

Answer

To change the content of the combo box cmbQ1_1, implement the following code:

procedure TForm1.btnQ1_1Click(Sender: TObject);
begin
  cmbQ1_1.Font.Size := 12;
  cmbQ1_1.Items.Add('Blue');
  cmbQ1_1.ItemIndex := 0; // Set 'Green' as the default item
end;

Step 2

Button [1.2 - Kite]

99%

104 rated

Answer

To calculate the area of the kite, you can use the following code:

var
  rArea: Real;
begin
  iDiagA := StrToInt(InputBox('Input', 'Enter diagonal A:', ''));
  iDiagB := StrToInt(InputBox('Input', 'Enter diagonal B:', ''));
  rArea := (iDiagA * iDiagB) / 2;
  lblQ1_2.Caption := FloatToStrF(rArea, ffFixed, 8, 1);
end;

Step 3

Button [1.3 - Binary number]

96%

101 rated

Answer

To convert the integer to binary, employ the following code:

var
iNumber, r: Integer;
sBinary: String;
begin
  iNumber := StrToInt(edtQ1_3.Text);
  sBinary := '';

  while iNumber > 0 do
  begin
    r := iNumber mod 2;
    sBinary := IntToStr(r) + sBinary; // Add remainder to string
    iNumber := iNumber div 2;
  end;

  lblQ1_3.Caption := sBinary;
end;

Step 4

Button [1.4 - Word game]

98%

120 rated

Answer

To compute the total points based on the characters in the word, use the following code:

var
  total: Integer;
  c: Char;
begin
  total := 0;
  word := UpperCase(edtQ1_4.Text);

  if Pos(' ', word) > 0 then // Check for spaces
  begin
    edtQ1_4.Clear;
    edtQ1_4.SetFocus;
    ShowMessage('Please enter a single word.');
  end
  else
  begin
    for i := 1 to Length(word) do
    begin
      c := word[i];
      if (c in ['A', 'E', 'I', 'O', 'U']) then
        total := total + 3
      else if CharInSet(c, ['A'..'Z']) then
        total := total + 2
      else
        total := total + 1;
    end;
    ShowMessage('Total value of word: ' + IntToStr(total));
  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

;