SECTION A
GENERAL PROGRAMMING SKILLS
Do the following:
Open the incomplete program in the Question 1 folder - NSC Information Technology - Question 1 - 2021 - Paper 1
Question 1
SECTION A
GENERAL PROGRAMMING SKILLS
Do the following:
Open the incomplete program in the Question 1 folder.
Enter your examination number as a comment in th... show full transcript
Worked Solution & Example Answer:SECTION A
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
FormCreate event
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
To set the properties of the label lblQ1_1:
Set the caption to 'Coding'.
Set the font color to green using: lblQ1_1.Font.Color := clGreen;
Set the font size to 16 pt with: lblQ1_1.Font.Size := 16;
Set the font name to 'Arial' using: lblQ1_1.Font.Name := 'Arial';
Step 2
Button [1.2 - Number of rolls]
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
In this case, define a constant for SWEETS_PER_ROLL and create integer variables:
Use const SWEETS_PER_ROLL = 8;.
Declare integer variables for storing breaks from the spin edit, total number of rolls, etc.
Extract the number of breaks from the spin edit box.
Calculate total number of rolls using:
ext{Total Rolls} = rac{ ext{Sweets}}{ ext{SWEETS_PER_ROLL}}
Round up using Ceil function,
Finally, display the total number of rolls in the label lblQ1_2.
Step 3
Button [1.3 - Calculate volume]
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
For the volume calculations:
Set rRadius := 3;.
The volume of the tetrahedron is given as 133 cm³. You can compute the volume of the sphere using:
Vsphere=34πr3
Calculate the combined volume as: Vcombined=133+21Vsphere
Finally, display the result in a ShowMessage box formatted to one decimal place.
Step 4
Button [1.4 - Display pattern]
98%
120 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
To display the pattern:
Clear the output area: redQ1_4.Clear;
Extract the symbol selected from cmbQ1_4.
Use iSize = Position of symbol in cmbQ1_4 + 1; to define the size of rows and columns.
Loop through rows from 0 to iSize, and for each row, loop through columns and print the symbol.
Construct the output using a string variable.
Step 5
Button [1.5 - Characters]
97%
117 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
To generate the random uppercase letter:
First, generate a random number r in the range 0 to 25, then convert it to a character using:
chr(r + 65) where 65 is the ASCII value for 'A'.
Use a loop to compile the string until the same letter is generated consecutively.