Photo AI

SECTION A QUESTION 1: GENERAL PROGRAMMING SKILLS Do the following: Open the incomplete program in the Question 1 folder - NSC Information Technology - Question 1 - 2021 - Paper 1

Question icon

Question 1

SECTION-A--QUESTION-1:--GENERAL-PROGRAMMING-SKILLS--Do-the-following:--Open-the-incomplete-program-in-the-Question-1-folder-NSC Information Technology-Question 1-2021-Paper 1.png

SECTION A QUESTION 1: GENERAL PROGRAMMING SKILLS Do the following: Open the incomplete program in the Question 1 folder. Enter your examination number as a comme... show full transcript

Worked Solution & Example Answer:SECTION A QUESTION 1: GENERAL PROGRAMMING SKILLS Do the following: Open the incomplete program in the Question 1 folder - NSC Information Technology - Question 1 - 2021 - Paper 1

Step 1

Button [1.1 - Calculate thickness of slices]

96%

114 rated

Answer

To calculate the thickness of the slices, begin with declaring the necessary variables:

var
  numberOfSlices: Integer;
  thicknessOfSlices: Real;

Next, extract the number of slices from the spin edit component:

numberOfSlices := spnQ1_1.Value;

Then, perform the calculation:

thicknessOfSlices := 242 / numberOfSlices;

Display the thickness in the label formatted to two decimal places:

lblQ1_1.Caption := FormatFloat('0.00', thicknessOfSlices);

Finally, ensure that the bread image is displayed properly:

imgQ1_1.Picture.LoadFromFile('bread_image_path');

Step 2

Button [1.2 - Calculate change]

99%

104 rated

Answer

First, declare a constant for the bread price:

const
  BREAD_PRICE = 12.90;

Extract the amount offered from the edit box:

var
  amountOffered: Real;
amountOffered := StrToFloat(edtAmount.Text);

Now, check if the offered amount is sufficient:

if amountOffered >= BREAD_PRICE then
begin
  change := amountOffered - BREAD_PRICE;
  lblChange.Caption := FormatFloat('Currency', change);
end else
begin
  lblChange.Caption := 'Insufficient amount offered';
end;

Step 3

Button [1.3 - Multiples of 10]

96%

101 rated

Answer

Initialize a counter and use a loop to find multiples of 10:

var
  counter: Integer;
  randomNumber: Integer;
begin
  counter := 0;
  for i := 1 to 10 do
  begin
    randomNumber := Random(100);
    if (randomNumber mod 10 = 0) and (randomNumber in [50..100]) then
    begin
      Inc(counter);
    end;
  end;
  lblOutput.Caption := 'Count of multiples of 10: ' + IntToStr(counter);
end;

Step 4

Button [1.4 - Hidden security code]

98%

120 rated

Answer

To compile the hidden security code, use a loop to process the paragraph:

var
  securityCode: string;
  i: Integer;
begin
  securityCode := '';
  for i := 1 to Length(sParagraph) do
  begin
    if sParagraph[i] = 't' then
    begin
      if (i > 1) and (sParagraph[i - 1] <> ' ') then
      begin
        securityCode := securityCode + sParagraph[i - 1];
      end;
    end;
    if Length(securityCode) >= 8 then
      Break;
  end;
  edtQ1_4.Text := UpperCase(securityCode);
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

;