Photo AI
Question 1
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
Step 1
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
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
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
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;
Report Improved Results
Recommend to friends
Students Supported
Questions answered