Do the following:
Open the incomplete program in the Question 1 folder - NSC Information Technology - Question 1 - 2021 - Paper 1
Question 1
Do the following:
Open the incomplete program in the Question 1 folder.
Enter your examination number as a comment in the first line of the Question1_U.pas file.
Co... show full transcript
Worked Solution & Example Answer:Do the following:
Open the incomplete program in the Question 1 folder - NSC Information Technology - Question 1 - 2021 - Paper 1
Step 1
Button [1.1 - Calculate thickness of slices]
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
In order to calculate the thickness of the slices,
Declare Variables: Define an integer variable for the number of slices and a real variable for the thickness of the slices.
Load Image: Use code to stretch the image correctly with imgQ1_1.Stretch := True;.
Get Input: Retrieve the number of slices from the spin edit component spnQ1_1, using numberOfSlices := spnQ1_1.Value;.
Calculate Thickness: Compute the thickness of each slice using the formula:
ext{Thickness of slice} = rac{242}{ ext{number of slices}}
Display Output: Format and display the calculated thickness in millimeters with two decimal places in lblQ1_1.Caption := FormatFloat('0.00', thicknessOfSlice);.
Step 2
Button [1.2 - Calculate change]
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
To calculate the change from a given amount:
Define Constant: Set a constant for the bread price (e.g., const BREAD_PRICE = 12.90;).
Get Amount Offered: Retrieve the amount entered by the user from the edit box.
Calculate Change: If the offered amount is greater than or equal to the bread price, compute the change:
extChange=extAmountOffered−BREADPRICE
Display Result: Show the change on the panel, formatted as currency. If insufficient, display a message indicating insufficient amount offered.
Step 3
Button [1.3 - Multiples of 10]
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
To check for multiples of 10:
Initialize Counter: Set a counter for multiples of 10 to zero.
Loop: Execute a loop 10 times:
Generate a random number between 50 and 100.
Display the random value.
Check if the random value is a multiple of 10 by using:
ext{if randomValue} mod 10 = 0
If true, increment the counter.
Output Result: After the loop, display the counter's value along with a message.
Step 4
Button [1.4 - Hidden security code]
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 compile the hidden security code from the paragraph:
Loop Through Paragraph: Loop through each character of sParagraph to find characters preceding 't'.
Check Conditions: For each character:
If the character before 't' is not a space, append it to sSecurityCode.
Ensure Length: Ensure that sSecurityCode does not exceed 8 characters.
Position Management: Maintain the position to find the next 't' character, using similar logic to track the characters.
Display Security Code: Finally, display the constructed security code in upper case in edt1_4.