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 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
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
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
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;
Report Improved Results
Recommend to friends
Students Supported
Questions answered