Task 1 Task 2 Task 3
Random Name

Task 1

A school register uses a computer program to manage attendance records in a school

A function, isPresent, needs to be implemented.

The function process a text file, attendance.txt which stores student names and ids on alternate lines. For example, a text file might store the following information:

Jones, Sally
sid-090
Tanaka, Masako
sid-110
Nguyen, Nguyen
sid-067
McArthur, Billy
sid-491
Laithwaite, Lily
sid-005

The function has a parameter, id, which is the id of a student to be searched for in the text file. The function returns the name of the student if the ID is found in the file, otherwise it returns "", an empy string.

The full header of the function in pseudocode is:

FUNCTION isPresent(id:STRING) RETURNS STRING

Write the program code to implement and test this function.

Random Name

Task 2

Another function, register, needs to be implemented by the school.

This function receives 2 STRINGS as parameters, a student name and a student ID.

The function checks that the ID is in the correct format (see samples above).

It also checks that the id is not currently in the file, attendance.txt

If the ID is in the correct format and the the ID is not currently in the file, both items of data are appended into the file and TRUE is returned, otherwise FALSE is returned.

The full header for the function is written in pseudocode as:

FUNCTION register(name:STRING, id:STRING) RETURNS BOOLEAN

Random Name

Task 3

For the 2 solutions above, submit PSEUDOCODE.