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 - 2019 - 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-2019-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 - 2019 - Paper 1

Step 1

Button [1.1 - Random number]

96%

114 rated

Answer

To generate a random number between 100 and 120, you can use the Random function and set the range using lower and upper limits. Display the generated number in the edtRandomNumber edit box by converting it to a string:

var
  randomNumber: Integer;
begin
  Randomize;
  randomNumber := Random(21) + 100; // Generates number from 100 to 120
  edtRandomNumber.Text := IntToStr(randomNumber);
end;

Step 2

Button [1.2 - Calculate minutes]

99%

104 rated

Answer

Extract the number of participants from the edtParticipants edit box and calculate the total minutes based on the criteria provided:

var
  participants, participantTime, totalMinutes: Integer;
begin
  participants := StrToInt(edtParticipants.Text);
  if participants <= 20 then
    participantTime := 2.5
  else if participants <= 50 then
    participantTime := 2.3
  else
    participantTime := 2;
  totalMinutes := Round(participants * participantTime);
  edtMinsRounded.Text := IntToStr(totalMinutes);
end;

Step 3

Button [1.3 - Calculate factorial]

96%

101 rated

Answer

To calculate the factorial of the selected number from the spnNumber, you can use a loop to multiply the numbers:

var
  number, factorial: Integer;
begin
  number := spnNumber.Value;
  factorial := 1;
  for i := 1 to number do
    factorial := factorial * i;
  edtFactorial.Text := IntToStr(factorial);
end;

Step 4

Button [1.4 - Reverse words]

98%

120 rated

Answer

To reverse the words in a sentence, split the sentence into individual words and reconstruct it in reverse order:

var
  originalSentence, newSentence: String;
  words: TArray<String>;
begin
  originalSentence := edtSentence.Text;
  words := originalSentence.Split([' ']);
  newSentence := '';
  for i := High(words) downto 0 do
    newSentence := newSentence + words[i] + ' ';
  edtReversed.Text := Trim(newSentence);
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

;