Assignment 3
Assignment 3
Assignment 3
Instructions:
This assignment will assess how well you have understood these topics. Make sure you
have read through the course materials for these topics before attempting this assignment.
o 9.1 - Computational Thinking Skills
o 9.2 - Introduction To Algorithms
o 10.1 - Introduction To Programming Theory
o 10.2 - Introduction To Abstract Data Types
o 11.1 - Pseudocode Basics
o 11.2 - Pseudocode – Selection
o 11.3 - Pseudocode – Iteration
o 11.4 - Pseudocode - Arrays and Records
o 11.5 - Pseudocode - Procedures and Functions
o 11.6 - Pseudocode – Files
o 12.1 - Program Development Life Cycles
o 12.2 - Program Design
o 12.3 - Program Testing and Maintenance
You must ensure that the work you submit for this assignment is your own. Your tutor may
use plagiarism checkers if they are concerned that your work has been copied from another
source.
Upon completion of this assignment, you will need to submit your work to your tutor by
following the instructions in the study guide. When marked, you will receive both your final
score and feedback from your tutor.
If you have any questions or need help, please contact your personal tutor for Computer
Science.
1 (a) Program variables have values as follows:
Variable Value
Today "Tuesday"
WeekNumber 37
Revision 'C'
MaxWeight 60.5
LastBatch TRUE
Today
WeekNumber
Revision
MaxWeight
LastBatch
Q1ai [5]
(ii) Evaluate each expression in the following table. If an expression is invalid then write ERROR.
Expression Evaluates to
INT(Maxweight + 4.2)
LENGTH(MaxWeight)
MOD(WeekNumber, 12)
Q1aii [5]
(b) Simple algorithms usually consist of input, process and output.
Complete the table to show if each statement is an example of input, process or output.
2 OUTPUT RIGHT(SomeChars,5)
Q1b [4]
(c) Write pseudocode to show how a repeat loop can be used to output all the odd numbers between 100
and 200.
Q1c [4]
2 Roberta downloads music from an online music store. The diagram shows part of a structure chart
for the online music store program.
(a) State three items of information that the diagram shows about the design of the program.
Q2a [3]
(b) Examples of the data items that correspond to the arrows are given in the table.
A 234.56
C TRUE
Use pseudocode to write the function header for the Card payment module.
Q2b [3]
3 A stack is created using a high-level language. The following diagram represents the current state of the
stack. The TopOfStack pointer points to the last item added to the stack.
Pointer
Address Value
99
100
101 E ⇐ TopOfStack
102 D
103 C
104 B
105 A
(a) Two operations associated with this stack are PUSH()and POP().
MyVar = POP()
PUSH('Z')
Q3a [4]
(b) Two programs use a stack to exchange data.
Program AddString pushes a string of characters onto the stack one character at a time.
Program RemoveString pops the same number of characters off the stack, one character at a time.
The string taken off the stack is different from the string put on the stack.
4 (a) Parameter x is used to pass data to procedure MyProc in the following pseudocode:
x ←4
CALL MyProc(x)
OUTPUT x
Q4a [6]
State two other features in the pseudocode that support a modular approach to programming.
Q4b [2]
5 A company keeps details of its product items in a 1D array, Stock.
ProductCode "BGR24-C"
Price 102.76
NumberInStock 15
Write pseudocode to output the information for each stock item that has a price of at least 100.
A function, ValidatePassword, is needed to check that a given password follows these rules. This
function takes a string, Pass, as a parameter and returns a boolean value:
(i) Give a valid password that can be used to check that the function returns TRUE under the correct
conditions.
Q6bi [1]
(ii) The password entered is modified to test each rule separately so that the function results FALSE.
(iii) When testing the ValidatePassword function a module it is necessary to test all possible paths
through the code including all internal structures.
(iv) A program consisting of several functions can be tested using a process known as ‘stub testing’
A procedure, LogEvents, is required to add data from the array to the end of the existing text file
LoginFile.txt
Unused array elements are assigned the value "Empty". These can occur anywhere in the array and should
not be added to the file.
END OF ASSIGNMENT
Please submit your work to your tutor by following the instructions in the study guide. When marked, you
will receive both your final score and feedback from your tutor.