2210/22 · May/June 2023
Download PDFFour logic gates and five standard symbols for logic gates are shown. Draw one line to link each logic gate to its standard symbol. Not all standard symbols will be used. Logic gate AND OR NAND NOT Standard symbol

Identify three different ways that the design of a solution to a problem can be presented. 1 ....................................................................................................................................................... .......................................................................................................................................................... 2 ....................................................................................................................................................... .......................................................................................................................................................... 3 ....................................................................................................................................................... ..........................................................................................................................................................
A program needs to make sure the value input for a measurement meets the following rules: • the value is a positive number • a value is always input • the value is less than 1000.
Describe the validation checks that the programmer would need to use.
The program needs editing to include a double entry check for the value input. State why this check needs to be included.
The input value needs to be stored in the variable Measurement Write pseudocode to perform the double entry check until a successful input is made.
State three different features of a high-level programming language that a programmer could use to make sure that their program will be easier to understand by another programmer. Give an example for each feature. Feature 1 .......................................................................................................................................... .......................................................................................................................................................... Example ........................................................................................................................................... .......................................................................................................................................................... Feature 2 .......................................................................................................................................... .......................................................................................................................................................... Example ........................................................................................................................................... .......................................................................................................................................................... Feature 3 .......................................................................................................................................... .......................................................................................................................................................... Example ........................................................................................................................................... ..........................................................................................................................................................
An algorithm has been written in pseudocode to calculate a check digit for a four-digit number. The algorithm then outputs the five-digit number including the check digit. The algorithm stops when –1 is input as the fourth digit. 01 Flag ← FALSE 02 REPEAT 03 Total ← 0 04 FOR Counter ← 1 TO 4 05 OUTPUT "Enter a digit ", Counter 06 INPUT Number[Counter] 07 Total ← Total + Number * Counter 08 IF Number[Counter] = 0 09 THEN 10 Flag ← TRUE 11 ENDIF 12 NEXT Counter 13 IF NOT Flag 14 THEN 15 Number[5] ← MOD(Total, 10) 16 FOR Counter ← 0 TO 5 17 OUTPUT Number[Counter] 18 NEXT 19 ENDIF 20 UNTIL Flag
Give the line number(s) for the statements showing: Totalling .................................................................................................................................... Count-controlled loop ............................................................................................................... Post-condition loop ...................................................................................................................
Identify the three errors in the pseudocode and suggest a correction for each error. Error 1 ....................................................................................................................................... Correction ................................................................................................................................. ................................................................................................................................................... Error 2 ....................................................................................................................................... Correction ................................................................................................................................. ................................................................................................................................................... Error 3 ....................................................................................................................................... Correction ................................................................................................................................. ...................................................................................................................................................
The algorithm does not check that each input is a single digit. Identify the place in the algorithm where this check should occur. Write pseudocode for this check. Your pseudocode must make sure that the input is a single digit and checks for –1 Place in algorithm ..................................................................................................................... Pseudocode .............................................................................................................................. ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ...................................................................................................................................................
Consider this logic expression. X = (A OR B) AND (NOT B AND C) Complete the truth table for this logic expression.
| A | B | C | Working space | X |
| 0 | 0 | 0 | ||
| 0 | 0 | 1 | ||
| 0 | 1 | 0 | ||
| 0 | 1 | 1 | ||
| 1 | 0 | 0 | ||
| 1 | 0 | 1 | ||
| 1 | 1 | 0 | ||
| 1 | 1 | 1 |

This flowchart represents an algorithm.

The array X[1:5] used in the flowchart contains this data:
| X[1] | X[2] | X[3] | X[4] | X[5] |
| 10 | 1 | 5 | 7 | 11 |
Complete the trace table by using the data given in the array.
| F | C | X[1] | X[2] | X[3] | X[4] | X[5] | T |
| 10 | 1 | 5 | 7 | 11 |
Describe what the algorithm represented by the flowchart is doing.
A music streaming service has a new database table named Songs to store details of songs available for streaming. The table contains the fields: • SongNumber – the catalogue number, for example AG123 • Title – the title of the song • Author – the name of the song writer(s) • Singer – the name of the singer(s) • Genre – the type of music, for example rock • Minutes – the length of the song in minutes, for example 3.75 • Recorded – the date the song was recorded.
Identify the field that will be the most appropriate primary key for this table.
Complete the table to identify the most appropriate data type for the fields in Songs
| Field | Data type |
| SongNumber | |
| Title | |
| Recorded | |
| Minutes |
Explain the purpose of the structured query language (SQL) statements. SUM (Minutes) FROM Songs WHERE Genre = "rock"; COUNT (Title) FROM Songs WHERE Genre = "rock";
The variables P and Q are used to store data in a program. P stores a string. Q stores a character.
Write pseudocode statements to declare the variables P and Q, store "The world" in P and store 'W' in Q
Write a pseudocode algorithm to: • convert P to upper case • find the position of Q in the string P (the first character in this string is in position 1) • store the position of Q in the variable Position
Give the value of Position after the algorithm has been executed with the data in question 11(a).
A two-dimensional (2D) array Account[] contains account holders’ names and passwords for a banking program. A 2D array AccDetails[] has three columns containing the following details: • column one stores the balance – the amount of money in the account, for example 250.00 • column two stores the overdraft limit – the maximum total amount an account holder can borrow from the bank after the account balance reaches 0.00, for example 100.00 • column three stores the withdrawal limit – the amount of money that can be withdrawn at one time, for example 200.00 The amount of money in a bank account can be negative (overdrawn) but not by more than the overdraft limit. For example, an account with an overdraft limit of 100.00 must have a balance that is greater than or equal to –100.00 Suitable error messages must be displayed if a withdrawal cannot take place, for example if the overdraft limit or the size of withdrawal is exceeded. The bank account ID gives the index of each account holder’s data held in the two arrays. For example, account ID 20’s details would be held in: Account[20,1] and Account[20,2] AccDetails[20,1] AccDetails[20,2] and AccDetails[20,3] The variable Size contains the number of accounts. The arrays and variable Size have already been set up and the data stored. Write a program that meets the following requirements: • checks the account ID exists and the name and password entered by the account holder match the name and password stored in Account[] before any action can take place • displays a menu showing the four actions available for the account holder to choose from: 1. display balance 2. withdraw money 3. deposit money 4. exit • allows an action to be chosen and completed. Each action is completed by a procedure with a parameter of the account ID. You must use pseudocode or program code and add comments to explain how your code works. All inputs and outputs must contain suitable messages. You only need to declare any local arrays and local variables that you use. You do not need to declare and initialise the data in the global arrays Account[] and AccDetails[] and the variable Size






