All posts by Mr Stratton

Computing teacher and a PT at Coltness High School.

New Logo

So a new theme requires a new logo. I have put some links to sites in other blog posts, check twitter. What can you come up with? you have a week to submit your finished logo before I go with something like this.

Homework for Tue 8th Nov 2011

A program is required which will take in a student’s Standard Grade ComputingStudies grade and decide which course, Intermediate 1, Intermediate 2 or Higheris the most appropriate. Standard Grade is issued on a scale of 1 to 7.
  1. Write the pseudocode for the part of the program which checks that the grade entered is a number between 1 and 7. (You should not need all the lines given!)
  2. Write the Visual BASIC line of code which displays a message box if an invalid grade is entered. The grade is stored in a variable called grade.
  3. Write the Visual BASIC line of code which displays a message box showing “Int 2” when the grade entered is either a 3 or a 4. The grade is stored in a variable called grade.
  4. Explain briefly what each of the following algorithms does:
  • Input validation
  • Finding a maximum
  • Finding a minimum
  • Counting occurrences
  • Linear search

4b. Write the pseudocode for the algorithms above
5. An array can be used to store variables. Explain what an array is, by using an example.

  • The values I am going to store in my example are:
  • I am going to create my array using this line of Visual BASIC code:
  • My array works like this:

Dice Roll Program

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'1 Set up Var
Dim dice(6000) As Integer
Dim results(6) As Integer
Dim target As Integer

'2 Roll 6000 dice
Call RollDice(dice)

'3 For Each Side of the dice
For Target = 1 To 6
'4 Count each side
Call count_occurrences(Target, dice, results(Target))
'5 next
Next

'6 Display
Call Display(results)
End Sub

Private Sub RollDice(ByRef dice() As Integer)
Dim counter As Integer
Randomize()
For counter = 1 To 6000
dice(counter) = Int(Rnd() * 6) + 1
Next
End Sub

Private Sub count_occurrences(ByVal target As Integer, ByRef Int_array() As Integer, ByRef counter As Integer)
'counting occurrences with an array of 10 strings
Dim pointer As Integer
counter = 0
For pointer = 1 To 6000
If Int_array(pointer) = target Then counter = counter + 1
Next
End Sub

Private Sub Display(ByRef results() As Integer)
Dim Counter
'clear listbox
lstOutput.Items.Clear()
'Display
For Counter = 1 To 6
lstOutput.Items.Add(Counter & vbTab & results(Counter))
Next
End Sub
End Class

Homework for 2/11/11

Sorry folks, I need to remember to check that automatic tasks launch, when they are meant to.

  1. What is meant when software is said to be modular?
  2. What is the disadvantage in using GLOBAL variables?
  3. What is the advantage in using LOCAL variables?
  4. Describe what a local variable is used for.
  5. Why should care be taken when using global variables?
  6. Give an extract of code which illustrates how a formal and actual parameters are used.
  7. Illustrate the difference in syntax between procedures/subroutines and functions.
  8. What is the advantage in using subprograms?
  9. Describe parameter passing by value.
  10. Describe parameter passing by reference.