SECTION A
QUESTION 1: 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
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
Worked Solution & Example Answer:SECTION A
QUESTION 1: 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
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
To calculate the thickness of the slices, follow these steps:
Declare Variables:
Declare an integer variable for the number of slices (numberOfSlices) and a real variable for the thickness (thicknessOfSlices).
Load Image:
Use a function to stretch and display the pre-loaded image in the imgQ1_1 component.
Retrieve Data:
Extract the number of slices from the spnQ1_1 spin edit component.
Calculate Thickness:
Implement the formula for thickness:
extthicknessOfSlices=numberOfSlices242
Format Output:
Display the calculated thickness in lblQ1_1. Ensure it is formatted to two decimal places.
Use formatting functions to achieve this.
This process ensures that the thickness of the slices is accurately calculated and displayed based on the user's input.
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
For this part, we need to calculate the change based on the amount offered:
Declare Constants and Variables:
Set a constant BREAD_PRICE to 12.90.
Declare a variable for the amount offered (amountOffered).
Retrieve Amount:
Extract the amount from the input edit box. Ensure it's converted to a float.
Calculate Change:
Check if amountOffered is greater than or equal to BREAD_PRICE:
If true, calculate the change:
change=amountOffered−BREADPRICE
Display the change on the panel as currency.
Else, display the message "Insufficient amount offered" on the panel.
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
For this section, we will find multiples of 10 within a specific range:
Counter Initialization:
Initialize a counter to store multiples of 10 (e.g., count = 0).
Loop Setup:
Create a loop to execute 10 times. Inside the loop:
Generate a random number between 50 and 100.
Display the random number.
Check if the random number is a multiple of 10. If it is, increment the counter.
Display Result:
After the loop ends, display the counter's value along with a relevant 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 sParagraph:
Initialize Loop:
Loop through the characters of sParagraph (from index 0 to the length of the paragraph).
Ensure the security code length is less than 8 characters.
Character Check:
For each character, check:
If the character precedes 't' in sParagraph, add it to the securityCode.
If the character at the index preceding a space isn't ' ', ignore it.
Output Security Code:
After constructing the security code, convert it to uppercase and display it in editQ1_4.