Showing posts with label AS_COM_Paper2. Show all posts
Showing posts with label AS_COM_Paper2. Show all posts

Wednesday, June 8, 2011

HTML+JS ON-THE-RUN

If you're really keen on coding and also maybe bored on the train? There's an App for that!
HTML Writer has coding shortcuts, its own testing browser, folder management and more. Get it HERE


Friday, March 25, 2011

Arrays - Searching

Do While FOUND = False AND SLOT <= ArrayLength            This will stop the looping at the 
If Array(SLOT) = SearchText then                                                           after checking the final slot
FOUND = True
Else
SLOT = SLOT + 1
Loop
If FOUND = True then
Message = "Yeah!"
else 
Message = "Not Found"
SLOT will start at 0 as a new variable that you would have DIM'd if making a full program
Remember you don't bother DIM'ing variables in the Exam

Arrays in Programming

Arrays group similar data together
It saves you DIM DIM DIM DIM
e.g. DIM NAMES(10) as STRING
Initialising means Create or Blank an array.
Initialising
Creating is NAME + SIZE + DATA TYPE (3 marks)
or
Blanking is:
For Slot = 1 to end
Array(slot) = 0
Next

FOR loop will go from beginning to end for 3 marks in the exam
DO WHILE loop allows you to report on a full array or a search being successful for 5 marks in the exam

Tuesday, March 22, 2011

VB Code for Average Test mark

Public Class Form1
    Dim Mark As Decimal
    Dim Listlength As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Mark = TextBox1.Text
        ListBox1.Items.Add(Mark)
        Listlength = Listlength + 1
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim OneMark As Integer
        Dim Total As Decimal
        Dim count As Integer
        Dim Average As Decimal
        Do
            ListBox1.SelectedIndex = count
            OneMark = ListBox1.SelectedItem
            Total = Total + OneMark
            count = count + 1
        Loop Until count = Listlength

        Average = Total / count
        TextBox2.Text = Average

    End Sub
End Class

Sudo Code - Working out Highest mark P1-J10-Q9b

PROCEDURE PRIZE                             Always Name the Procedure
OPEN FILE STUDENTS                        It says there's a File
SEARCH FOR FORM                             It only says it wants one Form done
SET HIGH = 0
WHILE NOT END OF STUDENTS, 
      DO CALL PROCEDURE MEAN     Start the loop by running the MEAN procedure
              IF AVERAGE > HIGH THEN    Check to see if the MEAN is the highest so far
                     HIGH = AVERAGE; STUDENT = CURRENT NAME; Save Mark as HIGH and Name
                     FLAG = FALSE 
             ELSE IF AVERAGE = HIGH THEN 
                    FLAG = TRUE                       They've used the FLAG variable to see if there's a draw
              ENDIF
ENDWHILE 
IF FLAG = TRUE THEN 
REPORT ‘Problem Equal high scorers’                        Report a draw or
ELSE OPEN FILE ‘PRIZES’                                           Open PRIZES file
COPY FORM AND STUDENT TO PRIZES ENDIF    Save the result (Mark & Name)
END

Pseudo Code - Work out an average P1-J10-Q9a

Calculate an average in 4 Marks
Procedure Mean                            1
Total = 0
Count = 0                                        1
DoWhile there's still marks          1
Get Mark
Count = Count + 1                         Running Total
Total = Total + Mark                      Running Total
EndWhile
Average = Total / Count               1       After all the looping
End Mean

Saturday, March 12, 2011

AS Programming Syllabus

Here is the Syllabus list for what you have to be able to write and read with programming.
(a) define and correctly use the following terms as they apply to procedural programming: statement, subroutine, procedure, function, parameter, loop
(b) identify the three basic programming constructs used to control the flow of execution: sequence, selection and iteration
(c) understand and use selection in pseudocode and a procedural programming language, including the use of IF statements and CASE/SELECT statements
(d) understand and use iteration in pseudocode and a procedural programming language, including the use of count-controlled loops (FOR-NEXT loops) and condition-controlled loops (WHILE-ENDWHILE and REPEAT_UNTIL loops)
(e) understand and use nested selection and nested iteration statements
(f) understand, create and use subroutines (procedures and functions), including the passing of parameters and the appropriate use of the return value of functions
(g) use subroutines to modularise the solution to a problem
(h) identify and use recursion to solve problems; show an understanding of the structure of a recursive subroutine, including the necessity of a stopping condition
(i) trace the execution of a recursive subroutine
 (j) discuss the relative merits of iterative and recursive solutions to the same problem

Wednesday, March 2, 2011