programming test #1 solutions. multiple choice 1. b) the grammar of the coding language 2. c) string...
TRANSCRIPT
Programming Test #1
Solutions
Multiple Choice
1. B) the grammar of the coding language
2. C) String
3. A) Single
4. C) 2Burgers4Me
5. B) Design Time
6. A) 1100 \ 24 / 4 mod 3
=100 \ 6 mod 3
=16 mod 3
=1
Multiple Choice (continued)
7. B) num mod 3 = 0Line 1dim sidelength as integer
Line 2dim area as integer
Line 3sidelength = 4
Line 4area = sidelength ^ 2
Line 5lbloutput.text = “The area of your square is” & area
8. A) line 1
9. C) line 5
10. D) The area of your square is16
Short Answer #1
It is called the Solution Explorer.
We use the buttons to show Code Window or Design Window. OR
We use this window to give our form and application filenames. OR
We use this window to view all parts of our project.
Short Answer # 2
To explain to others what our code is doing. -- other programmers, the teacher, other students
Explains the logic and clarifies our code.
Short Answer #3
1. Input from User
2. Output to User
3. Mathematical Calculations
4. Storing Data (Variables)
5. Conditional Statements (If)
6. Repeating Statements (Loops)
Short Answer #4
a) What is an event?• Clicking a button, loading a form, changing
the text in the textbox … something the user does to interact with our program
b) What is an event procedure?• The section of code for an object
c) How are the two connected?• The event must occur to execute the code in
the event procedure.
Code Writing *(simple logic)
‘declare variablesDim total as singleDim pepperoni as singleDim cheese as singleDim onion as singleEtc.
Private Sub chkPepperoni …If chkPepperoni.checked = true then
pepperoni = 2End if
Private Sub optLarge …If optLarge.checked = true then
large = 15.5End if
Private Sub cmdCalculateCost …total = pepperoni + large + small + cheese + onion + tomato + olive + baconlblOutputCost.text = “The cost of your pizza is $” & total
Code Writing **(better way)
‘declare variablesDim cost as single
Private Sub chkPepperoni …If chkPepperoni.Checked = True then
cost = cost + 2Else
cost = cost - 2End If
Private Sub optLarge …If optLarge.Checked = True then
cost = cost + 15.5Else
cost = cost - 2End If
Private Sub btnCalculateCostlblOutputCost.Text = “The cost of your pizza is $” & cost
**stuff in Pink was extra … level 3 without it – customers may change mind, and you uncheck .. the Pink code will then subtract the amount from the total
**also earned extra marks for only using one variable