SlideShare une entreprise Scribd logo
1  sur  11
Télécharger pour lire hors ligne
2
9608/22/PRE/M/J/19© UCLES 2019
Teachers and candidates should read this material prior to the June 2019 examination for 9608 Paper 2.
Reminders
The syllabus states:
• there will be questions on the examination paper which do not relate to this pre-release material.
• you must choose a high-level programming language from this list:
o Visual Basic (console mode)
o Python
o Pascal / Delphi (console mode)
Note: A mark of zero will be awarded if a programming language other than those listed is used.
Questions on the examination paper may ask the candidate to write:
• structured English
• pseudocode
• program code
A program flowchart should be considered as an alternative to pseudocode for the documenting of an
algorithm design.
Candidates should be confident with:
• the presentation of an algorithm using either a program flowchart or pseudocode
• the production of a program flowchart from given pseudocode and vice versa
Some tasks may need one or more of the built-in functions or operators listed in the Appendix at the
end of this document.
There will be a similar appendix at the end of the question paper.
Declaration of variables
The syllabus document shows the syntax expected for a declaration statement in pseudocode.
DECLARE <identifier> : <data type>
If Python is the chosen language, each variable’s identifier (name) and its intended data type must be
documented using a comment statement.
Structured English – Variables
An algorithm in pseudocode uses variables, which should be declared. An algorithm in structured
English does not always use variables. In this case, the candidate needs to use the information given
in the question to complete an identifier table. The table needs to contain an identifier, data type and
description for each variable.
3
9608/22/PRE/M/J/19© UCLES 2019 [Turn over
TASK 1 – Arrays
Introduction
Candidates should be able to write programs to process array data both in pseudocode and in their
chosen programming language. It is suggested that each task is planned using pseudocode before
writing it in program code.
TASK 1.1
A 1D array of STRING data type will be used to store the name of each student in a class together with
their email address as follows:
<StudentName>'#'<EmailAddress>
An example string with this format would be:
"Eric Smythe#eric@email.com"
Write program code to:
1. declare the array
2. prompt and input name and email address
3. form the string as shown
4. write the string to the next array element
5. repeat from step 2 for all students in the class
6. output each element of the array in a suitable format, together with explanatory text such as
column headings
TASK 1.2
Consider what happens when a student leaves the class and their data item is deleted from the array.
Decide on a way of identifying unused array elements and only output elements that contain student
details. Modify your program to include this.
TASK 1.3
Extend your program so that after assigning values to the array, the program will prompt the user to
input a name, and then search the array to find that name and output the corresponding email address.
TASK 1.4
Modify your program so that it will:
• prompt the user to input part, or the whole, of a name
• search the whole array to find the search term within the <StudentName> string
• for each array element in which the search term is found within the <StudentName> string, output
the element in a suitable format.
4
9608/22/PRE/M/J/19© UCLES 2019
TASK 1.5
Convert your design to use a 2D array and add additional pieces of information for each student.
For example:
Array element Information Example data
MyArray[1,1] Student Name "Tim Smith"
MyArray[1,2] Email Address "TimSmith1099@email.com"
MyArray[1,3] Date of Birth "15/05/2001"
MyArray[1,4] Student ID "C3452-B"
TASK 1.6
Modify your program to work with the new structure.
Task 1.1
​'1 - Declaration of array to hold student records
​Dim​ clsRecords(30) As String
​Dim​ i As Integer
​For​ i = 0 ​to​ 29
clsRecords(i) = ​"---"
​Next
​'4 and 5 - Writing record to the array
​'nextElement - Acts as a pointer for accessing next blocks in the array
​'cond - Gives choice to the user whether to continue or quit
​Dim​ nextElement As Integer = 0
​Dim​ cond As String
​Do
​'2 - User Prompts
​Dim​ name As String
​Dim​ email As String
Console.WriteLine(​"Enter name: "​)
name = Console.ReadLine()
Console.WriteLine(​"Enter email: "​)
email = Console.ReadLine()
​'3 - Formatting of string as per the requirement
​Dim​ record As String = name & ​"#"​ & email
​'Record is getting written to the array
clsRecords(nextElement) = record
nextElement = nextElement + 1
​'User prompt for either continuing to add record or stop
Console.WriteLine(​"Any key to continue, S - stop: "​)
cond = Console.ReadLine()
​Loop​ Until cond = ​"S"​ ​or​ nextElement = 29
​'6 - Output
Console.WriteLine(​"Student Name#Email Address"​)
Console.WriteLine(​"--------------------------"​)
​For​ i = 0 ​to​ 29
Console.WriteLine(clsRecords(i))
​Next
1
Task 1.2
Console.WriteLine(​"Student Name#Email Address"​)
Console.WriteLine(​"--------------------------"​)
​For​ i = 0 ​to​ 29
​'Task 1.2 - To display only the current records
​If​ clsRecords(i) <> ​"---"​ ​Then
Console.WriteLine(clsRecords(i))
​End​ ​If
​Next
Task 1.3
​'Task 1.3 Searching a record and display its corresponding email
'Conditional variable that will determine whether user wants to keep
'searching or quit the loop
​Dim​ cond1 As String
​Do
'Prompt to ask name of the student
​Dim​ name1 As String
Console.WriteLine(​"Enter name: "​)
name1 = Console.ReadLine()
Console.WriteLine(​"Student Name#Email Address"​)
Console.WriteLine(​"--------------------------"​)
​For​ i = 0 ​to​ 29
​If​ clsRecords(i) <> ​"---"​ ​Then
​ 'If name in the record equals name entered, email will be
'displayed
​If​ clsRecords(i).Substring(0, name1.length) = name1 ​Then
Console.WriteLine(clsRecords(i).Substring(name1.length +1))
​End​ ​If
​End​ ​If
​Next
'Prompt whether to search for student name again or stop searching
Console.WriteLine(​"Any key to continue searching, S - Stop"​)
cond1 = Console.ReadLine()
​Loop​ Until cond1 = ​"S"
2
Task 1.4
​'Task 1.4 Searching a record by inputting full or part of the name and
'display the records
'Conditional variable that will determine whether user wants to keep
'searching or quit the loop
​Dim​ cond1 As String
​Do
​Dim​ name1 As String
Console.WriteLine(​"Enter name: "​)
name1 = Console.ReadLine()
​ 'Flag variable to indicate whether full or part of name is found
'In a record
​Dim​ flag As Boolean = ​False
Console.WriteLine(​"Student Name#Email Address"​)
Console.WriteLine(​"--------------------------"​)
​For​ i = 0 ​to​ 29
​If​ clsRecords(i) <> ​"---"​ ​Then
​'IndexOf method allows to search full name or part of the name
'Within the contagious records in the array.
'If record(s) found, flag variable is set to True.
​If​ clsRecords(i).IndexOf(name1) <> -1 ​Then
Console.WriteLine(clsRecords(i))
flag = ​True
​End​ ​If
​End​ ​If
​Next
'If no records found, flag not be set to True and will remain False.
'This will indicate no record is found in the array.
​If​ flag = ​False
Console.WriteLine(​"No Record found!"​)
​End​ ​If
'Prompt whether to search for student name again or stop searching
Console.WriteLine(​"Any key to continue searching, S - Stop"​)
cond1 = Console.ReadLine()
​Loop​ Until cond1 = ​"S"
3
Task 1.5 and Task 1.6 - Repeating Tasks 1.1 - 1.4 using 2D array
Task 1.1
​'1 - Declaration of 2D Arrays to hold student records
​Dim​ clsRecords(30,4) As String
​Dim​ row, col As Integer
'For accessing inner arrays or rows
​For​ row = 0 ​to​ 29
'For accessing elements by each column
​For​ col = 0 ​to​ 3
'Each empty block in the array will be represented by “---”
clsRecords(row, col) = ​"---"
​Next
​Next
​'4 and 5 - Writing all of the details to the empty blocks of array
'nexetRecord - Acts as a pointer for accessing next row. Each row is responsible to
'hold details of a student
'cond - Gives choice to the user whether to continue or quit
​Dim​ nextRecord As Integer
​Dim​ cond As String
​Do
'2 - User prompts
​Dim​ name As String
​Dim​ email As String
​Dim​ dob As String
​Dim​ studentID As String
Console.Writeline(​"Enter name: "​)
name = Console.Readline()
Console.Writeline(​"Enter email: "​)
email = Console.Readline()
Console.Writeline(​"Enter date of birth: "​)
dob = Console.Readline()
Console.Writeline(​"Enter student ID: "​)
studentID = Console.Readline()
'3 - All the details of a student are getting added in each of the blocks
'of the inner array
​'Name of the student is stored in the first block of the row
clsRecords(nextRecord, 0) = name
4
'Email address of the student is stored in the second block
clsRecords(nextRecord, 1) = email
'Date of birth of the student is stored in the third block
clsRecords(nextRecord, 2) = dob
'StudentID of the student is stored in the fourth block
clsRecords(nextRecord, 3) = studentID
​'Pointer is updated to move to the next row
nextRecord = nextRecord + 1
'User prompt for either continuing to add record or stop
Console.Writeline(​"Any key to continue, S - stop: "​)
cond = Console.Readline()
​Loop​ Until cond = ​"S"​ ​or​ cond = ​"s" ​or ​nextRecord = 29
'6 - Output
Console.Writeline(​"Student Name#Email Address#Date of Birth#Student ID"​)
Console.Writeline(​"---------------------------------------------------"​)
For​ row = 0 ​to​ 29
​For​ col = 0 ​to​ 3
​'To display elements of a row in same line followed by a separator - “#”
Console.Write(clsRecords(row, col) & ​"#"​)
​Next
'Once all details of a student is displayed, we move to the next line for
'Displaying the record of another student
Console.Writeline()
​Next
Task 1.2
Console.Writeline(​"Student Name#Email Address#Date of Birth#Student ID"​)
Console.Writeline(​"---------------------------------------------------"​)
​'flag variable - To allow moving to the next line only if a record is found
'This will prevent printing unnecessary blank lines.
Dim​ flag As Boolean = ​False
For​ row = 0 ​to​ 29
​For​ col = 0 ​to​ 3
​'To prevent printing empty slots in the console. Each elements or cells
'are checked if the slot is empty.
​If​ clsRecords(row, col) <> ​"---"​ ​Then
Console.Write(clsRecords(row, col) & ​"#"​)
​'After record of a student is displayed, flag is set to true
flag = ​True
​End​ ​If
5
​Next
'flag = True represents the record of a student is detected and will only
'allow moving to the next line after record of a student is displayed.
'After moving to next line, flag is then again set to False so that if row of
'are not detected, flag will remain False, and we then do not move to the next
'line.
​If​ flag = ​True​ ​Then
Console.Writeline()
flag = ​False
​End​ ​If
​Next
Task 1.3
​ 'Conditional variable that will determine whether user wants to keep
'searching or quit the loop
​ ​Dim​ ​cond1 As String
​Do
​'Prompt to ask name of the student
​Dim​ ​name1 As String
​ Console.Writeline(​"Enter name: "​)
​name1 = Console.Readline()
'Column headers
​Console.Writeline(​"StudentName#EmailAddress#DateofBirth#StudentID"​)
Console.Writeline(​"----------------------------------------------"​)
​Dim​ ​row1, col1 As Integer
​Dim​ ​flag1 As Boolean =​ ​False
​For​ ​row1 = 0​ ​to​ ​29
​For​ ​col1 = 0​ ​to​ ​3
​If​ ​clsRecords(row1, col1) <>​ ​"---"​ ​Then
​'First cell of the row is checked if it equals the name
'that is entered by the user.
'If True, next line is executed and email is displayed of
'the respective student of whose name was entered.
​If​ ​clsRecords(row1, 0) = name1​ ​Then
​ Console.Writeline(clsRecords(row1,1))
​flag1 = ​True
'Once email address is displayed, it is necessary to
'exit the inner loop as it will repeat itself, and then
'more than once, same email will be displayed as we
'explicitly pass number 1 to access the second column.
​exit​ ​for
​End​ ​if
6
​End​ ​If
​Next
​If​ ​flag1 =​ ​True​ ​Then
​Console.Writeline()
​flag1 = ​False
​End​ ​if
​Next
​Console.Writeline(​"Any key to continue, S - stop: "​)
​ cond1 = Console.Readline()
​Loop​ ​Until cond1 = ​"S" ​or​ ​cond1​ ​= ​"s"
Task 1.4
​Dim​ cond1 As String
​Do
​Dim​ name1 As String
Console.Writeline(​"Enter name: "​)
name1 = Console.Readline()
'Column headers
​Console.Writeline(​"StudentName#EmailAddress#DateofBirth#StudentID"​)
Console.Writeline(​"----------------------------------------------"​)
​Dim​ row1, col1 As Integer
​Dim​ flag1 As Boolean = ​False
​For​ row1 = 0 ​to​ 29
​For​ col1 = 0 ​to​ 3
​If​ clsRecords(row1, col1) <> ​"---"​ ​Then
​'If full name includes part of the name, then record(s)
'Of those students will be displayed.
​If​ clsRecords(row1, 0).IndexOf(name1) <> -1 ​Then
Console.Write(clsRecords(row1, col1) & ​"#"​)
flag1 = ​True
​'Here we don’t need to exit loop in advance as col1
'variable gets incremented at the end of the loop which
'will then allow us to access all of the elements of
'inner row(s) and therefore display details of
'student(s)
​End​ ​if
​End​ ​If
​Next
​If​ flag1 = ​True​ ​Then
Console.Writeline()
flag1 = ​False
​End​ ​if
7
​Next
Console.Writeline(​"Any key to continue, S - stop: "​)
cond1 = Console.Readline()
​Loop​ Until cond1 = ​"S"
8

Contenu connexe

Tendances

Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryTsegazeab Asgedom
 
Python Data Types.pdf
Python Data Types.pdfPython Data Types.pdf
Python Data Types.pdfNehaSpillai1
 
systems programming lab programs in c
systems programming lab programs in csystems programming lab programs in c
systems programming lab programs in cMeghna Roy
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languagesparmeet834
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programmingNeeru Mittal
 
pseudocode and Flowchart
pseudocode and Flowchartpseudocode and Flowchart
pseudocode and FlowchartALI RAZA
 
Ascii and Unicode (Character Codes)
Ascii and Unicode (Character Codes)Ascii and Unicode (Character Codes)
Ascii and Unicode (Character Codes)Project Student
 
Theory of Computation
Theory of ComputationTheory of Computation
Theory of ComputationShiraz316
 
Logic gates - AND, OR, NOT, NOR, NAND, XOR, XNOR Gates.
Logic gates - AND, OR, NOT, NOR, NAND, XOR, XNOR Gates.Logic gates - AND, OR, NOT, NOR, NAND, XOR, XNOR Gates.
Logic gates - AND, OR, NOT, NOR, NAND, XOR, XNOR Gates.Satya P. Joshi
 
Fundamentals of algorithms
Fundamentals of algorithmsFundamentals of algorithms
Fundamentals of algorithmsAmit Kumar Rathi
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Animesh Chaturvedi
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithmsGanesh Solanke
 
Chapter 1 Programming Fundamentals Assignment.docx
Chapter 1 Programming Fundamentals Assignment.docxChapter 1 Programming Fundamentals Assignment.docx
Chapter 1 Programming Fundamentals Assignment.docxShamshad
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsMohamed Loey
 
Non- Deterministic Algorithms
Non- Deterministic AlgorithmsNon- Deterministic Algorithms
Non- Deterministic AlgorithmsDipankar Boruah
 

Tendances (20)

Pumping lemma
Pumping lemmaPumping lemma
Pumping lemma
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata Theory
 
Python Data Types.pdf
Python Data Types.pdfPython Data Types.pdf
Python Data Types.pdf
 
Python Tutorial Part 2
Python Tutorial Part 2Python Tutorial Part 2
Python Tutorial Part 2
 
systems programming lab programs in c
systems programming lab programs in csystems programming lab programs in c
systems programming lab programs in c
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
 
Introduction to problem solving in C
Introduction to problem solving in CIntroduction to problem solving in C
Introduction to problem solving in C
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
 
pseudocode and Flowchart
pseudocode and Flowchartpseudocode and Flowchart
pseudocode and Flowchart
 
Ascii and Unicode (Character Codes)
Ascii and Unicode (Character Codes)Ascii and Unicode (Character Codes)
Ascii and Unicode (Character Codes)
 
Theory of Computation
Theory of ComputationTheory of Computation
Theory of Computation
 
Logic gates - AND, OR, NOT, NOR, NAND, XOR, XNOR Gates.
Logic gates - AND, OR, NOT, NOR, NAND, XOR, XNOR Gates.Logic gates - AND, OR, NOT, NOR, NAND, XOR, XNOR Gates.
Logic gates - AND, OR, NOT, NOR, NAND, XOR, XNOR Gates.
 
Bfs and Dfs
Bfs and DfsBfs and Dfs
Bfs and Dfs
 
Fundamentals of algorithms
Fundamentals of algorithmsFundamentals of algorithms
Fundamentals of algorithms
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
Chapter 1 Programming Fundamentals Assignment.docx
Chapter 1 Programming Fundamentals Assignment.docxChapter 1 Programming Fundamentals Assignment.docx
Chapter 1 Programming Fundamentals Assignment.docx
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 
Non- Deterministic Algorithms
Non- Deterministic AlgorithmsNon- Deterministic Algorithms
Non- Deterministic Algorithms
 

Similaire à 9608 Computer Science Cambridge International AS level Pre-Release May June paper 22 2019 Tasks 1.1 - 1.6

Micro project project co 3i
Micro project project co 3iMicro project project co 3i
Micro project project co 3iARVIND SARDAR
 
Ee java lab assignment 3
Ee java lab assignment 3Ee java lab assignment 3
Ee java lab assignment 3Kuntal Bhowmick
 
MICRO PROJECT 22319 DMS
MICRO PROJECT 22319 DMSMICRO PROJECT 22319 DMS
MICRO PROJECT 22319 DMSARVIND SARDAR
 
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21chinthala Vijaya Kumar
 
Assignment Java Programming 2
Assignment Java Programming 2Assignment Java Programming 2
Assignment Java Programming 2Kaela Johnson
 
classes object fgfhdfgfdgfgfgfgfdoop.pptx
classes object  fgfhdfgfdgfgfgfgfdoop.pptxclasses object  fgfhdfgfdgfgfgfgfdoop.pptx
classes object fgfhdfgfdgfgfgfgfdoop.pptxarjun431527
 
Cmps 260, fall 2021 programming assignment #3 (125 points)
Cmps 260, fall 2021 programming assignment #3 (125 points)Cmps 260, fall 2021 programming assignment #3 (125 points)
Cmps 260, fall 2021 programming assignment #3 (125 points)mehek4
 
Ee java lab assignment 3
Ee java lab assignment 3Ee java lab assignment 3
Ee java lab assignment 3Kuntal Bhowmick
 
Student Lab Activity CIS170 Week 6 Lab Instructions.docx
Student Lab Activity CIS170 Week 6 Lab Instructions.docxStudent Lab Activity CIS170 Week 6 Lab Instructions.docx
Student Lab Activity CIS170 Week 6 Lab Instructions.docxflorriezhamphrey3065
 
Section1 compound data class
Section1 compound data classSection1 compound data class
Section1 compound data classDương Tùng
 
RANDOM TESTS COMBINING MATHEMATICA PACKAGE AND LATEX COMPILER
RANDOM TESTS COMBINING MATHEMATICA PACKAGE AND LATEX COMPILERRANDOM TESTS COMBINING MATHEMATICA PACKAGE AND LATEX COMPILER
RANDOM TESTS COMBINING MATHEMATICA PACKAGE AND LATEX COMPILERijseajournal
 
Cosc 1436 java programming/tutorialoutlet
Cosc 1436 java programming/tutorialoutletCosc 1436 java programming/tutorialoutlet
Cosc 1436 java programming/tutorialoutletWoodardz
 
This is my code but not complete, please complete my.pdf
This is my code but not complete, please complete my.pdfThis is my code but not complete, please complete my.pdf
This is my code but not complete, please complete my.pdffashionbigchennai
 
22316-2019-Summer-model-answer-paper.pdf
22316-2019-Summer-model-answer-paper.pdf22316-2019-Summer-model-answer-paper.pdf
22316-2019-Summer-model-answer-paper.pdfPradipShinde53
 
Excel analysis assignment this is an independent assignment me
Excel analysis assignment this is an independent assignment meExcel analysis assignment this is an independent assignment me
Excel analysis assignment this is an independent assignment mejoney4
 
COSC 2436 – PROJECT Contents TITLE ..................docx
COSC 2436 – PROJECT Contents TITLE ..................docxCOSC 2436 – PROJECT Contents TITLE ..................docx
COSC 2436 – PROJECT Contents TITLE ..................docxbobbywlane695641
 

Similaire à 9608 Computer Science Cambridge International AS level Pre-Release May June paper 22 2019 Tasks 1.1 - 1.6 (20)

Micro project project co 3i
Micro project project co 3iMicro project project co 3i
Micro project project co 3i
 
Dbms record
Dbms recordDbms record
Dbms record
 
Ee java lab assignment 3
Ee java lab assignment 3Ee java lab assignment 3
Ee java lab assignment 3
 
MICRO PROJECT 22319 DMS
MICRO PROJECT 22319 DMSMICRO PROJECT 22319 DMS
MICRO PROJECT 22319 DMS
 
Project3
Project3Project3
Project3
 
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
 
Assignment Java Programming 2
Assignment Java Programming 2Assignment Java Programming 2
Assignment Java Programming 2
 
classes object fgfhdfgfdgfgfgfgfdoop.pptx
classes object  fgfhdfgfdgfgfgfgfdoop.pptxclasses object  fgfhdfgfdgfgfgfgfdoop.pptx
classes object fgfhdfgfdgfgfgfgfdoop.pptx
 
C++
C++C++
C++
 
Cmps 260, fall 2021 programming assignment #3 (125 points)
Cmps 260, fall 2021 programming assignment #3 (125 points)Cmps 260, fall 2021 programming assignment #3 (125 points)
Cmps 260, fall 2021 programming assignment #3 (125 points)
 
Ee java lab assignment 3
Ee java lab assignment 3Ee java lab assignment 3
Ee java lab assignment 3
 
Student Lab Activity CIS170 Week 6 Lab Instructions.docx
Student Lab Activity CIS170 Week 6 Lab Instructions.docxStudent Lab Activity CIS170 Week 6 Lab Instructions.docx
Student Lab Activity CIS170 Week 6 Lab Instructions.docx
 
Section1 compound data class
Section1 compound data classSection1 compound data class
Section1 compound data class
 
RANDOM TESTS COMBINING MATHEMATICA PACKAGE AND LATEX COMPILER
RANDOM TESTS COMBINING MATHEMATICA PACKAGE AND LATEX COMPILERRANDOM TESTS COMBINING MATHEMATICA PACKAGE AND LATEX COMPILER
RANDOM TESTS COMBINING MATHEMATICA PACKAGE AND LATEX COMPILER
 
Object-Oriented Programming Using C++
Object-Oriented Programming Using C++Object-Oriented Programming Using C++
Object-Oriented Programming Using C++
 
Cosc 1436 java programming/tutorialoutlet
Cosc 1436 java programming/tutorialoutletCosc 1436 java programming/tutorialoutlet
Cosc 1436 java programming/tutorialoutlet
 
This is my code but not complete, please complete my.pdf
This is my code but not complete, please complete my.pdfThis is my code but not complete, please complete my.pdf
This is my code but not complete, please complete my.pdf
 
22316-2019-Summer-model-answer-paper.pdf
22316-2019-Summer-model-answer-paper.pdf22316-2019-Summer-model-answer-paper.pdf
22316-2019-Summer-model-answer-paper.pdf
 
Excel analysis assignment this is an independent assignment me
Excel analysis assignment this is an independent assignment meExcel analysis assignment this is an independent assignment me
Excel analysis assignment this is an independent assignment me
 
COSC 2436 – PROJECT Contents TITLE ..................docx
COSC 2436 – PROJECT Contents TITLE ..................docxCOSC 2436 – PROJECT Contents TITLE ..................docx
COSC 2436 – PROJECT Contents TITLE ..................docx
 

Plus de Isham Rashik

Text Preprocessing - 1
Text Preprocessing - 1Text Preprocessing - 1
Text Preprocessing - 1Isham Rashik
 
Fundamentals of Cryptography - Caesar Cipher - Python
Fundamentals of Cryptography - Caesar Cipher - Python Fundamentals of Cryptography - Caesar Cipher - Python
Fundamentals of Cryptography - Caesar Cipher - Python Isham Rashik
 
Python 3.x Dictionaries and Sets Cheatsheet
Python 3.x Dictionaries and Sets CheatsheetPython 3.x Dictionaries and Sets Cheatsheet
Python 3.x Dictionaries and Sets CheatsheetIsham Rashik
 
HackerRank Repeated String Problem
HackerRank Repeated String ProblemHackerRank Repeated String Problem
HackerRank Repeated String ProblemIsham Rashik
 
Operations Management - BSB INC - Case Study
Operations Management - BSB INC - Case StudyOperations Management - BSB INC - Case Study
Operations Management - BSB INC - Case StudyIsham Rashik
 
Corporate Finance - Disney Sea Park Project
Corporate Finance - Disney Sea Park ProjectCorporate Finance - Disney Sea Park Project
Corporate Finance - Disney Sea Park ProjectIsham Rashik
 
Questionnaire - Why women entrepreneurs are happier than men?
Questionnaire - Why women entrepreneurs are happier than men?Questionnaire - Why women entrepreneurs are happier than men?
Questionnaire - Why women entrepreneurs are happier than men?Isham Rashik
 
Human Resource Management - Different Interview Techniques
Human Resource Management - Different Interview TechniquesHuman Resource Management - Different Interview Techniques
Human Resource Management - Different Interview TechniquesIsham Rashik
 
Python 3.x File Object Manipulation Cheatsheet
Python 3.x File Object Manipulation CheatsheetPython 3.x File Object Manipulation Cheatsheet
Python 3.x File Object Manipulation CheatsheetIsham Rashik
 
Android Application Development - Level 3
Android Application Development - Level 3Android Application Development - Level 3
Android Application Development - Level 3Isham Rashik
 
Android Application Development - Level 2
Android Application Development - Level 2Android Application Development - Level 2
Android Application Development - Level 2Isham Rashik
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1Isham Rashik
 
Managerial Skills Presentation - Elon Musk
Managerial Skills Presentation - Elon MuskManagerial Skills Presentation - Elon Musk
Managerial Skills Presentation - Elon MuskIsham Rashik
 
Operations Management - Business Process Reengineering - Example
Operations Management - Business Process Reengineering - ExampleOperations Management - Business Process Reengineering - Example
Operations Management - Business Process Reengineering - ExampleIsham Rashik
 
Lighting Design - Theory and Calculations
Lighting Design - Theory and CalculationsLighting Design - Theory and Calculations
Lighting Design - Theory and CalculationsIsham Rashik
 
Linear Control Hard-Disk Read/Write Controller Assignment
Linear Control Hard-Disk Read/Write Controller AssignmentLinear Control Hard-Disk Read/Write Controller Assignment
Linear Control Hard-Disk Read/Write Controller AssignmentIsham Rashik
 
Transformers and Induction Motors
Transformers and Induction MotorsTransformers and Induction Motors
Transformers and Induction MotorsIsham Rashik
 
Three phase balanced load circuits and synchronous generators
Three phase balanced load circuits and synchronous generatorsThree phase balanced load circuits and synchronous generators
Three phase balanced load circuits and synchronous generatorsIsham Rashik
 
Circuit Breakers for Low Voltage Applications
Circuit Breakers for Low Voltage ApplicationsCircuit Breakers for Low Voltage Applications
Circuit Breakers for Low Voltage ApplicationsIsham Rashik
 
Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet Isham Rashik
 

Plus de Isham Rashik (20)

Text Preprocessing - 1
Text Preprocessing - 1Text Preprocessing - 1
Text Preprocessing - 1
 
Fundamentals of Cryptography - Caesar Cipher - Python
Fundamentals of Cryptography - Caesar Cipher - Python Fundamentals of Cryptography - Caesar Cipher - Python
Fundamentals of Cryptography - Caesar Cipher - Python
 
Python 3.x Dictionaries and Sets Cheatsheet
Python 3.x Dictionaries and Sets CheatsheetPython 3.x Dictionaries and Sets Cheatsheet
Python 3.x Dictionaries and Sets Cheatsheet
 
HackerRank Repeated String Problem
HackerRank Repeated String ProblemHackerRank Repeated String Problem
HackerRank Repeated String Problem
 
Operations Management - BSB INC - Case Study
Operations Management - BSB INC - Case StudyOperations Management - BSB INC - Case Study
Operations Management - BSB INC - Case Study
 
Corporate Finance - Disney Sea Park Project
Corporate Finance - Disney Sea Park ProjectCorporate Finance - Disney Sea Park Project
Corporate Finance - Disney Sea Park Project
 
Questionnaire - Why women entrepreneurs are happier than men?
Questionnaire - Why women entrepreneurs are happier than men?Questionnaire - Why women entrepreneurs are happier than men?
Questionnaire - Why women entrepreneurs are happier than men?
 
Human Resource Management - Different Interview Techniques
Human Resource Management - Different Interview TechniquesHuman Resource Management - Different Interview Techniques
Human Resource Management - Different Interview Techniques
 
Python 3.x File Object Manipulation Cheatsheet
Python 3.x File Object Manipulation CheatsheetPython 3.x File Object Manipulation Cheatsheet
Python 3.x File Object Manipulation Cheatsheet
 
Android Application Development - Level 3
Android Application Development - Level 3Android Application Development - Level 3
Android Application Development - Level 3
 
Android Application Development - Level 2
Android Application Development - Level 2Android Application Development - Level 2
Android Application Development - Level 2
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1
 
Managerial Skills Presentation - Elon Musk
Managerial Skills Presentation - Elon MuskManagerial Skills Presentation - Elon Musk
Managerial Skills Presentation - Elon Musk
 
Operations Management - Business Process Reengineering - Example
Operations Management - Business Process Reengineering - ExampleOperations Management - Business Process Reengineering - Example
Operations Management - Business Process Reengineering - Example
 
Lighting Design - Theory and Calculations
Lighting Design - Theory and CalculationsLighting Design - Theory and Calculations
Lighting Design - Theory and Calculations
 
Linear Control Hard-Disk Read/Write Controller Assignment
Linear Control Hard-Disk Read/Write Controller AssignmentLinear Control Hard-Disk Read/Write Controller Assignment
Linear Control Hard-Disk Read/Write Controller Assignment
 
Transformers and Induction Motors
Transformers and Induction MotorsTransformers and Induction Motors
Transformers and Induction Motors
 
Three phase balanced load circuits and synchronous generators
Three phase balanced load circuits and synchronous generatorsThree phase balanced load circuits and synchronous generators
Three phase balanced load circuits and synchronous generators
 
Circuit Breakers for Low Voltage Applications
Circuit Breakers for Low Voltage ApplicationsCircuit Breakers for Low Voltage Applications
Circuit Breakers for Low Voltage Applications
 
Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet
 

Dernier

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 

Dernier (20)

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 

9608 Computer Science Cambridge International AS level Pre-Release May June paper 22 2019 Tasks 1.1 - 1.6

  • 1. 2 9608/22/PRE/M/J/19© UCLES 2019 Teachers and candidates should read this material prior to the June 2019 examination for 9608 Paper 2. Reminders The syllabus states: • there will be questions on the examination paper which do not relate to this pre-release material. • you must choose a high-level programming language from this list: o Visual Basic (console mode) o Python o Pascal / Delphi (console mode) Note: A mark of zero will be awarded if a programming language other than those listed is used. Questions on the examination paper may ask the candidate to write: • structured English • pseudocode • program code A program flowchart should be considered as an alternative to pseudocode for the documenting of an algorithm design. Candidates should be confident with: • the presentation of an algorithm using either a program flowchart or pseudocode • the production of a program flowchart from given pseudocode and vice versa Some tasks may need one or more of the built-in functions or operators listed in the Appendix at the end of this document. There will be a similar appendix at the end of the question paper. Declaration of variables The syllabus document shows the syntax expected for a declaration statement in pseudocode. DECLARE <identifier> : <data type> If Python is the chosen language, each variable’s identifier (name) and its intended data type must be documented using a comment statement. Structured English – Variables An algorithm in pseudocode uses variables, which should be declared. An algorithm in structured English does not always use variables. In this case, the candidate needs to use the information given in the question to complete an identifier table. The table needs to contain an identifier, data type and description for each variable.
  • 2. 3 9608/22/PRE/M/J/19© UCLES 2019 [Turn over TASK 1 – Arrays Introduction Candidates should be able to write programs to process array data both in pseudocode and in their chosen programming language. It is suggested that each task is planned using pseudocode before writing it in program code. TASK 1.1 A 1D array of STRING data type will be used to store the name of each student in a class together with their email address as follows: <StudentName>'#'<EmailAddress> An example string with this format would be: "Eric Smythe#eric@email.com" Write program code to: 1. declare the array 2. prompt and input name and email address 3. form the string as shown 4. write the string to the next array element 5. repeat from step 2 for all students in the class 6. output each element of the array in a suitable format, together with explanatory text such as column headings TASK 1.2 Consider what happens when a student leaves the class and their data item is deleted from the array. Decide on a way of identifying unused array elements and only output elements that contain student details. Modify your program to include this. TASK 1.3 Extend your program so that after assigning values to the array, the program will prompt the user to input a name, and then search the array to find that name and output the corresponding email address. TASK 1.4 Modify your program so that it will: • prompt the user to input part, or the whole, of a name • search the whole array to find the search term within the <StudentName> string • for each array element in which the search term is found within the <StudentName> string, output the element in a suitable format.
  • 3. 4 9608/22/PRE/M/J/19© UCLES 2019 TASK 1.5 Convert your design to use a 2D array and add additional pieces of information for each student. For example: Array element Information Example data MyArray[1,1] Student Name "Tim Smith" MyArray[1,2] Email Address "TimSmith1099@email.com" MyArray[1,3] Date of Birth "15/05/2001" MyArray[1,4] Student ID "C3452-B" TASK 1.6 Modify your program to work with the new structure.
  • 4. Task 1.1 ​'1 - Declaration of array to hold student records ​Dim​ clsRecords(30) As String ​Dim​ i As Integer ​For​ i = 0 ​to​ 29 clsRecords(i) = ​"---" ​Next ​'4 and 5 - Writing record to the array ​'nextElement - Acts as a pointer for accessing next blocks in the array ​'cond - Gives choice to the user whether to continue or quit ​Dim​ nextElement As Integer = 0 ​Dim​ cond As String ​Do ​'2 - User Prompts ​Dim​ name As String ​Dim​ email As String Console.WriteLine(​"Enter name: "​) name = Console.ReadLine() Console.WriteLine(​"Enter email: "​) email = Console.ReadLine() ​'3 - Formatting of string as per the requirement ​Dim​ record As String = name & ​"#"​ & email ​'Record is getting written to the array clsRecords(nextElement) = record nextElement = nextElement + 1 ​'User prompt for either continuing to add record or stop Console.WriteLine(​"Any key to continue, S - stop: "​) cond = Console.ReadLine() ​Loop​ Until cond = ​"S"​ ​or​ nextElement = 29 ​'6 - Output Console.WriteLine(​"Student Name#Email Address"​) Console.WriteLine(​"--------------------------"​) ​For​ i = 0 ​to​ 29 Console.WriteLine(clsRecords(i)) ​Next 1
  • 5. Task 1.2 Console.WriteLine(​"Student Name#Email Address"​) Console.WriteLine(​"--------------------------"​) ​For​ i = 0 ​to​ 29 ​'Task 1.2 - To display only the current records ​If​ clsRecords(i) <> ​"---"​ ​Then Console.WriteLine(clsRecords(i)) ​End​ ​If ​Next Task 1.3 ​'Task 1.3 Searching a record and display its corresponding email 'Conditional variable that will determine whether user wants to keep 'searching or quit the loop ​Dim​ cond1 As String ​Do 'Prompt to ask name of the student ​Dim​ name1 As String Console.WriteLine(​"Enter name: "​) name1 = Console.ReadLine() Console.WriteLine(​"Student Name#Email Address"​) Console.WriteLine(​"--------------------------"​) ​For​ i = 0 ​to​ 29 ​If​ clsRecords(i) <> ​"---"​ ​Then ​ 'If name in the record equals name entered, email will be 'displayed ​If​ clsRecords(i).Substring(0, name1.length) = name1 ​Then Console.WriteLine(clsRecords(i).Substring(name1.length +1)) ​End​ ​If ​End​ ​If ​Next 'Prompt whether to search for student name again or stop searching Console.WriteLine(​"Any key to continue searching, S - Stop"​) cond1 = Console.ReadLine() ​Loop​ Until cond1 = ​"S" 2
  • 6. Task 1.4 ​'Task 1.4 Searching a record by inputting full or part of the name and 'display the records 'Conditional variable that will determine whether user wants to keep 'searching or quit the loop ​Dim​ cond1 As String ​Do ​Dim​ name1 As String Console.WriteLine(​"Enter name: "​) name1 = Console.ReadLine() ​ 'Flag variable to indicate whether full or part of name is found 'In a record ​Dim​ flag As Boolean = ​False Console.WriteLine(​"Student Name#Email Address"​) Console.WriteLine(​"--------------------------"​) ​For​ i = 0 ​to​ 29 ​If​ clsRecords(i) <> ​"---"​ ​Then ​'IndexOf method allows to search full name or part of the name 'Within the contagious records in the array. 'If record(s) found, flag variable is set to True. ​If​ clsRecords(i).IndexOf(name1) <> -1 ​Then Console.WriteLine(clsRecords(i)) flag = ​True ​End​ ​If ​End​ ​If ​Next 'If no records found, flag not be set to True and will remain False. 'This will indicate no record is found in the array. ​If​ flag = ​False Console.WriteLine(​"No Record found!"​) ​End​ ​If 'Prompt whether to search for student name again or stop searching Console.WriteLine(​"Any key to continue searching, S - Stop"​) cond1 = Console.ReadLine() ​Loop​ Until cond1 = ​"S" 3
  • 7. Task 1.5 and Task 1.6 - Repeating Tasks 1.1 - 1.4 using 2D array Task 1.1 ​'1 - Declaration of 2D Arrays to hold student records ​Dim​ clsRecords(30,4) As String ​Dim​ row, col As Integer 'For accessing inner arrays or rows ​For​ row = 0 ​to​ 29 'For accessing elements by each column ​For​ col = 0 ​to​ 3 'Each empty block in the array will be represented by “---” clsRecords(row, col) = ​"---" ​Next ​Next ​'4 and 5 - Writing all of the details to the empty blocks of array 'nexetRecord - Acts as a pointer for accessing next row. Each row is responsible to 'hold details of a student 'cond - Gives choice to the user whether to continue or quit ​Dim​ nextRecord As Integer ​Dim​ cond As String ​Do '2 - User prompts ​Dim​ name As String ​Dim​ email As String ​Dim​ dob As String ​Dim​ studentID As String Console.Writeline(​"Enter name: "​) name = Console.Readline() Console.Writeline(​"Enter email: "​) email = Console.Readline() Console.Writeline(​"Enter date of birth: "​) dob = Console.Readline() Console.Writeline(​"Enter student ID: "​) studentID = Console.Readline() '3 - All the details of a student are getting added in each of the blocks 'of the inner array ​'Name of the student is stored in the first block of the row clsRecords(nextRecord, 0) = name 4
  • 8. 'Email address of the student is stored in the second block clsRecords(nextRecord, 1) = email 'Date of birth of the student is stored in the third block clsRecords(nextRecord, 2) = dob 'StudentID of the student is stored in the fourth block clsRecords(nextRecord, 3) = studentID ​'Pointer is updated to move to the next row nextRecord = nextRecord + 1 'User prompt for either continuing to add record or stop Console.Writeline(​"Any key to continue, S - stop: "​) cond = Console.Readline() ​Loop​ Until cond = ​"S"​ ​or​ cond = ​"s" ​or ​nextRecord = 29 '6 - Output Console.Writeline(​"Student Name#Email Address#Date of Birth#Student ID"​) Console.Writeline(​"---------------------------------------------------"​) For​ row = 0 ​to​ 29 ​For​ col = 0 ​to​ 3 ​'To display elements of a row in same line followed by a separator - “#” Console.Write(clsRecords(row, col) & ​"#"​) ​Next 'Once all details of a student is displayed, we move to the next line for 'Displaying the record of another student Console.Writeline() ​Next Task 1.2 Console.Writeline(​"Student Name#Email Address#Date of Birth#Student ID"​) Console.Writeline(​"---------------------------------------------------"​) ​'flag variable - To allow moving to the next line only if a record is found 'This will prevent printing unnecessary blank lines. Dim​ flag As Boolean = ​False For​ row = 0 ​to​ 29 ​For​ col = 0 ​to​ 3 ​'To prevent printing empty slots in the console. Each elements or cells 'are checked if the slot is empty. ​If​ clsRecords(row, col) <> ​"---"​ ​Then Console.Write(clsRecords(row, col) & ​"#"​) ​'After record of a student is displayed, flag is set to true flag = ​True ​End​ ​If 5
  • 9. ​Next 'flag = True represents the record of a student is detected and will only 'allow moving to the next line after record of a student is displayed. 'After moving to next line, flag is then again set to False so that if row of 'are not detected, flag will remain False, and we then do not move to the next 'line. ​If​ flag = ​True​ ​Then Console.Writeline() flag = ​False ​End​ ​If ​Next Task 1.3 ​ 'Conditional variable that will determine whether user wants to keep 'searching or quit the loop ​ ​Dim​ ​cond1 As String ​Do ​'Prompt to ask name of the student ​Dim​ ​name1 As String ​ Console.Writeline(​"Enter name: "​) ​name1 = Console.Readline() 'Column headers ​Console.Writeline(​"StudentName#EmailAddress#DateofBirth#StudentID"​) Console.Writeline(​"----------------------------------------------"​) ​Dim​ ​row1, col1 As Integer ​Dim​ ​flag1 As Boolean =​ ​False ​For​ ​row1 = 0​ ​to​ ​29 ​For​ ​col1 = 0​ ​to​ ​3 ​If​ ​clsRecords(row1, col1) <>​ ​"---"​ ​Then ​'First cell of the row is checked if it equals the name 'that is entered by the user. 'If True, next line is executed and email is displayed of 'the respective student of whose name was entered. ​If​ ​clsRecords(row1, 0) = name1​ ​Then ​ Console.Writeline(clsRecords(row1,1)) ​flag1 = ​True 'Once email address is displayed, it is necessary to 'exit the inner loop as it will repeat itself, and then 'more than once, same email will be displayed as we 'explicitly pass number 1 to access the second column. ​exit​ ​for ​End​ ​if 6
  • 10. ​End​ ​If ​Next ​If​ ​flag1 =​ ​True​ ​Then ​Console.Writeline() ​flag1 = ​False ​End​ ​if ​Next ​Console.Writeline(​"Any key to continue, S - stop: "​) ​ cond1 = Console.Readline() ​Loop​ ​Until cond1 = ​"S" ​or​ ​cond1​ ​= ​"s" Task 1.4 ​Dim​ cond1 As String ​Do ​Dim​ name1 As String Console.Writeline(​"Enter name: "​) name1 = Console.Readline() 'Column headers ​Console.Writeline(​"StudentName#EmailAddress#DateofBirth#StudentID"​) Console.Writeline(​"----------------------------------------------"​) ​Dim​ row1, col1 As Integer ​Dim​ flag1 As Boolean = ​False ​For​ row1 = 0 ​to​ 29 ​For​ col1 = 0 ​to​ 3 ​If​ clsRecords(row1, col1) <> ​"---"​ ​Then ​'If full name includes part of the name, then record(s) 'Of those students will be displayed. ​If​ clsRecords(row1, 0).IndexOf(name1) <> -1 ​Then Console.Write(clsRecords(row1, col1) & ​"#"​) flag1 = ​True ​'Here we don’t need to exit loop in advance as col1 'variable gets incremented at the end of the loop which 'will then allow us to access all of the elements of 'inner row(s) and therefore display details of 'student(s) ​End​ ​if ​End​ ​If ​Next ​If​ flag1 = ​True​ ​Then Console.Writeline() flag1 = ​False ​End​ ​if 7
  • 11. ​Next Console.Writeline(​"Any key to continue, S - stop: "​) cond1 = Console.Readline() ​Loop​ Until cond1 = ​"S" 8