0% found this document useful (0 votes)
3 views2 pages

Example Algorithms

The document outlines algorithms for reading and writing delimited files, focusing on tasks such as school litter collection, checking student availability, calculating DP, marking question papers, generating bank statements, and storing sign-up details. It includes detailed steps for using file parsers, loops, and conditionals to process data effectively. Each section provides a structured approach to handling specific file operations and user input validation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Example Algorithms

The document outlines algorithms for reading and writing delimited files, focusing on tasks such as school litter collection, checking student availability, calculating DP, marking question papers, generating bank statements, and storing sign-up details. It includes detailed steps for using file parsers, loops, and conditionals to process data effectively. Each section provides a structured approach to handling specific file operations and user input validation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Reading Delimited Files Algorithms:

School Litter Collection:


 Open data file using TextFieldParser and declare a variable that will read it.
 Set the type of the text field.
 Set the value for the delimiter.
 Declare variables to store the table data.
 Declare the formatted string.
 Set the font for the list box table.
 Create a loop that will read the file.
 Store the data values from the file into the different table variables.
 Add the data to the list box table.

Check Your DP:


 Create Boolean Function stuAvail() that:
 Uses a Text field parser to read the marks.txt file.
Declares variables for the student number and the Boolean to check if the student number
appears in the file.
Sets the type of file being read.
Sets delimiter.
Uses while loop to read all fields and lines of the file and uses and If statement to check if
the student number is in the file.
 Create Integer Function calcDP() that takes your student number as an argument:
 Reads the file marks.txt like the previous function.
Declares variables for the student number and different assessment marks recorded in the
txt file.
Declares a variable that will store the DP.
Uses a while loop to read through the text file.
Sets the different variables to the different data values from the text file.
Uses an If statement to search for the student number and when it finds it, it uses the
other values to calculate the DP.
Returns DP
 Uses the two functions to calculate your DP from inputting your student number.

Reading Mark down Files Algorithms:


Question Paper Marker:
 Create a Stream reader variable to read the text file.
 Declare variables for the answer and an array for the answers from the memo.txt
 Declare i variable for handling the index of the memo array.
 Declare marks variable to calculate the total mark that the student receives.
 Close the file.
 Uses a Combo boxes and a text box to ask the student questions and take their answers.
 Uses If Statements to check if the answers from the different combo boxes and text box are
the same as the answers from the memo array, if they are, 1 is added to marks variable.
 Displays that total mark on a Label.
Writing Mark down Files Algorithms:
Bank Statement Generator:
 Declare variable ID to collect the identity number from a text box.
 Use A Stream reader to read bankDetails.txt.
 Declare a variable for the StreamWriter, that sets the second argument to True to create a
new file.
 Declare variables for all the information stored in the bankDetails.txt file.
 Set the text field type and the delimiter.
 Use a while loop to read through the file and set each variable name to a different data value
from the text file.
 Us If statement to search for the ID number in the text file.
 If the ID number is found use the stream writer variable to write the details that are on the
same field as the ID number in different lines in the generated text file.
 Close the stream writer.

Writing Delimited Files Algorithms:


Sign Up details storer:
 Declare a variable for the stream writer.
 Declare variables for name, surname, email, phone number, password and re-entering the
password.
 Use the variables to store values from different text boxes you use to collect information.
 Use an If statement to check if the two passwords match.
 If the do write the values of the variables in the generated file.
 If they do not match, clear the text boxes used to collect the two passwords so you can re
enter them.

You might also like