programming test #1 solutions. multiple choice 1. b) the grammar of the coding language 2. c) string...

9
Programming Test #1 Solutions

Upload: ross-craig

Post on 02-Jan-2016

219 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 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

Programming Test #1

Solutions

Page 2: 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

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

Page 3: 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

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

Page 4: 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

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.

Page 5: 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

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.

Page 6: 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

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)

Page 7: 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

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.

Page 8: 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

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

Page 9: 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

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