Photo AI
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. Enter your ex... show full transcript
Step 1
Step 2
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
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
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;
Report Improved Results
Recommend to friends
Students Supported
Questions answered