Individual Assignment C Programming
Individual Assignment C Programming
INSTRUCTIONS TO CANDIDATES:
1. Submit your assignment online in MS Teams unless advised otherwise
4. You must obtain at least 50% in each component to pass this module
C INDIVIDUAL ASSIGNMENT APU1F2209
Table of Contents
1.0 INTRODUCTION........................................................................................................................................3
2.0 ASSUMPTIONS................................................................................................................................................3
3.0 PSEUDOCODE.................................................................................................................................................4
4.0 SAMPLE OUTPUTS.......................................................................................................................................21
4.1 MAIN MENU..............................................................................................................................................21
4.2 ADMIN MENU...........................................................................................................................................22
4.3 REGISTER TUTOR....................................................................................................................................23
4.4 ADD SESSION............................................................................................................................................25
4.5 REGISTER STUDENT...............................................................................................................................27
4.6 ENROL STUDENT IN SESSION...............................................................................................................29
4.7 LIST OF SESSIONS AND PARTICIPATING STUDENTS.....................................................................31
4.8 TUTOR MENU............................................................................................................................................32
4.9 LISTINGS OF SESSIONS AND STUDENTS (TUTOR MENU)..............................................................34
4.10 STUDENT MENU.....................................................................................................................................35
4.11 LISTINGS OF SESSIONS (STUDENT MENU)......................................................................................37
4.12 ENROLL INTO A SESSION (STUDENT MENU)..................................................................................38
5.0 CONCLUSION................................................................................................................................................41
6.0 REFERENCES.................................................................................................................................................42
pg. 2
C INDIVIDUAL ASSIGNMENT APU1F2209
1.0 INTRODUCTION
APU decided to establish an experimental programme named "Programming Café" to offer extra
coding sessions for students outside of their regular timetable to improve their performance, improve
their problem-solving ability, and increase their confidence level in coding. Two hours will be allotted
for each session, which will all take place in a designated classroom. Programming Café sessions will
be guided by carefully chosen APU Graduate Students who are proficient in the relevant programming
language. These students will get a flat charge of RM100 for each TWO-hour session they lead. For
the Programming Café Sessions in this trial phase, APU has chosen a few popular programming
languages. This assignment requires the implementation of features such as tutor registration, session
assignment, student registration, student enrollment, and listing of sessions and participating students.
The ultimate objective is to create an efficient and user-friendly system that effectively manages the
Programming Café sessions, fostering an environment of continuous learning and skill development in
coding.
2.0 ASSUMPTIONS
The Programming Café sessions are open to all students at APU who are interested in improving their
coding skills, regardless of their academic program or level of study. It is optional and not mandatory
for students to attend. It is a supplementary program designed to provide additional coding sessions
outside of their regular timetable. The duration of each Programming Café session is fixed at two
hours, and the sessions are conducted in a classroom assigned specifically for this purpose.
The listed programming languages in Table 1 (Python, Java, C, Web Development, and C Sharp) are
the initial sessions selected for the Programming Café program during the experimental phase.
Additional sessions on different coding subjects can be added as needed. Moreover, the system
mentioned in the requirements is a software application or platform that will assist in managing the
Programming Café Sessions. It will provide different features and functionalities based on the user
type (Admin, Tutor, or Student) after successful login with the appropriate credentials.
The registration process for tutors and students involves collecting basic details such as name, TP
number (for students), and assigning passwords for login purposes. Each session can only be assigned
to one tutor, and one tutor can only take up one session. This ensures that there is a clear assignment of
tutors to specific programming languages. Besides that, students can enroll themselves in any available
session of their choice, allowing them to participate in the Programming Café program according to
their interests and learning goals. The system should be able to provide listings of the Programming
Café sessions, including the participating students, session codes, tutor codes, and locations. This
information will help in organizing and tracking the sessions effectively.
pg. 3
C INDIVIDUAL ASSIGNMENT APU1F2209
3.0 PSEUDOCODE
STRUCT Admin:
tutorCode[50]
tutorPassword[50]
programTitle[50]
tutorName[50]
sessionTitle[50]
sessionCode[50]
sessionDay[50]
startTime[50]
sessionLocation[50]
studentName[50]
tpNumber[50]
studentPassword[50]
STRUCT Tutor:
tutorCode[50]
tutorPassword[50]
programTitle[50]
tutorName[50]
sessionCode[50]
sessionTitle[50]
studentName[50]
tpNumber[50]
startTime[50]
sessionLocation[50]
STRUCT Student:
tpNumber[50]
studentName[50]
studentPassword[50]
tutorCode[50]
tutorPassword[50]
programTitle[50]
tutorName[50]
sessionCode[50]
sessionTitle[50]
startTime[50]
sessionLocation[50]
FUNCTION tutorRegistration():
DECLARE tutorRegister AS Admin
pg. 4
C INDIVIDUAL ASSIGNMENT APU1F2209
DECLARE tutor_Id[50]
DECLARE tutor_Name[50]
DECLARE tutor_Password[50]
DECLARE class_Title[50]
DECLARE rcdfound = 0
pg. 5
C INDIVIDUAL ASSIGNMENT APU1F2209
fclose(fptr)
CALL admin()
END FUNCTION
FUNCTION newSession():
DECLARE tutorRegister AS Admin
DECLARE newSession AS Admin
DECLARE session_Title[50]
DECLARE session_Code[50]
DECLARE session_Day[50]
DECLARE start_Time[50]
DECLARE session_Location[50]
DECLARE tutor_Code[50]
DECLARE rcdfound = 0
DECLARE rcdfound1 = 0
DECLARE fp AS FILE*
fp = fopen("new_Session.txt", "a+")
IF fp IS NULL THEN
PRINT "File not available"
END IF
pg. 6
C INDIVIDUAL ASSIGNMENT APU1F2209
// If the tutor and session combination exists, check if the session already exists in
new_Session.txt
IF rcdfound == 1 THEN
WHILE fscanf(fp, "%[^/]/%[^/]/%[^/]/%[^/]/%[^/]/%[^\n]\n", newSession.sessionCode,
newSession.sessionTitle, newSession.sessionDay, newSession.startTime,
newSession.sessionLocation, newSession.tutorCode) != EOF DO
IF strcmp(session_Code, newSession.sessionCode) == 0 AND strcmp(session_Title,
newSession.sessionTitle) == 0 AND strcmp(tutor_Code, newSession.tutorCode) == 0 THEN
SET rcdfound1 = 1
BREAK
END IF
END WHILE
IF rcdfound1 == 0 THEN
// Write the new session record to new_Session.txt
strcpy(newSession.sessionCode, session_Code)
strcpy(newSession.sessionTitle, session_Title)
strcpy(newSession.sessionDay, session_Day)
strcpy(newSession.startTime, start_Time)
strcpy(newSession.sessionLocation, session_Location)
strcpy(newSession.tutorCode, tutor_Code)
fprintf(fp, "%s/%s/%s/%s/%s/%s\n", newSession.sessionCode, newSession.sessionTitle,
newSession.sessionDay, newSession.startTime, newSession.sessionLocation,
newSession.tutorCode)
PRINT "The record has been updated in the text file"
ELSE
PRINT "The session has already existed in the text file"
pg. 7
C INDIVIDUAL ASSIGNMENT APU1F2209
END IF
ELSE
PRINT "The session and tutor code does not exist!"
END IF
fclose(fptr)
fclose(fp)
CALL admin()
END FUNCTION
FUNCTION studentRegistration():
DECLARE studentRegister AS Admin
DECLARE student_Name[50]
DECLARE tp_Number[50]
DECLARE student_Password[50]
DECLARE rcdfound = 0
IF rcdfound == 0 THEN
pg. 8
C INDIVIDUAL ASSIGNMENT APU1F2209
fclose(fptr1)
CALL admin()
END FUNCTION
FUNCTION studentEnrolment():
DECLARE studentRegister AS Admin
DECLARE newSession AS Admin
DECLARE studentEnrol AS Admin
DECLARE session_Title[50]
DECLARE session_Code[50]
DECLARE session_Day[50]
DECLARE start_Time[50]
DECLARE session_Location[50]
DECLARE tutor_Code[50]
DECLARE student_Name[50]
DECLARE tp_Number[50]
DECLARE tutor_Id[50]
DECLARE tutor_Name[50]
DECLARE tutor_Password[50]
DECLARE rcdfound = 0
DECLARE rcdfound1 = 0
DECLARE Enrolled = 0
DECLARE fp AS FILE*
fp = fopen("new_Session.txt", "r")
IF fp IS NULL THEN
PRINT "File not available"
END IF
pg. 9
C INDIVIDUAL ASSIGNMENT APU1F2209
IF rcdfound == 1 THEN
// Check if the session exists in new_Session.txt
WHILE fscanf(fp, "%[^/]/%[^/]/%[^/]/%[^/]/%[^/]/%[^\n]\n", newSession.sessionCode,
newSession.sessionTitle, newSession.sessionDay, newSession.startTime,
newSession.sessionLocation, newSession.tutorCode) != EOF DO
IF strcmp(session_Code, newSession.sessionCode) == 0 AND strcmp(session_Title,
newSession.sessionTitle) == 0 AND strcmp(tutor_Id, newSession.tutorCode) == 0 THEN
SET rcdfound1 = 1
BREAK
END IF
pg. 10
C INDIVIDUAL ASSIGNMENT APU1F2209
END WHILE
IF rcdfound1 == 1 THEN
// Check if the student is already enrolled in the session
WHILE fscanf(fptr2, "%[^/]/%[^/]/%[^/]/%[^/]/%[^/]/%[^/]/%[^\n]\n",
studentEnrol.sessionCode, studentEnrol.sessionTitle, studentEnrol.tpNumber,
studentEnrol.studentName, studentEnrol.tutorCode, studentEnrol.startTime,
studentEnrol.sessionLocation) != EOF DO
IF strcmp(session_Code, studentEnrol.sessionCode) == 0 AND strcmp(session_Title,
studentEnrol.sessionTitle) == 0 AND strcmp(tutor_Id, studentEnrol.tpNumber) == 0 THEN
SET Enrolled = 1
BREAK
END IF
END WHILE
IF Enrolled == 0 THEN
// Enroll the student in the session
strcpy(studentEnrol.sessionCode, session_Code)
strcpy(studentEnrol.sessionTitle, session_Title)
strcpy(studentEnrol.tpNumber, tp_Number)
strcpy(studentEnrol.studentName, student_Name)
strcpy(studentEnrol.tutorCode, tutor_Id)
strcpy(studentEnrol.startTime, newSession.startTime)
strcpy(studentEnrol.sessionLocation, newSession.sessionLocation)
fprintf(fptr2, "%s/%s/%s/%s/%s/%s/%s\n", studentEnrol.sessionCode,
studentEnrol.sessionTitle, studentEnrol.tpNumber, studentEnrol.studentName,
studentEnrol.tutorCode, studentEnrol.startTime, studentEnrol.sessionLocation)
PRINT "The record has been added to the text file."
ELSE
PRINT "The student is already enrolled in the session."
END IF
ELSE
PRINT "The session does not exist."
END IF
ELSE
PRINT "The student information does not exist."
END IF
fclose(fptr2)
fclose(fp)
fclose(fptr1)
CALL admin()
END FUNCTION
pg. 11
C INDIVIDUAL ASSIGNMENT APU1F2209
FUNCTION listings():
DECLARE studentEnrol AS Admin
fclose(fptr2)
CALL admin()
END FUNCTION
FUNCTION admin():
DECLARE option AS Integer
PRINT
"============================================================="
PRINT "|Welcome to the Admin Menu |"
PRINT
"============================================================="
PRINT "|User options: |"
PRINT "| |"
PRINT "|[1] Register Tutor |"
PRINT "|[2] Add Session |"
PRINT "|[3] Register Student |"
PRINT "|[4] Enrol Student in Session |"
PRINT "|[5] List Sessions and Participating Students |"
PRINT "|[6] Exit to main menu |"
PRINT
pg. 12
C INDIVIDUAL ASSIGNMENT APU1F2209
"============================================================="
PRINT "Please choose one option (1-6): "
READ option
SWITCH option DO
CASE 1:
CALL tutorRegistration()
BREAK
CASE 2:
CALL newSession()
BREAK
CASE 3:
CALL studentRegistration()
BREAK
CASE 4:
CALL studentEnrolment()
BREAK
CASE 5:
CALL listings()
BREAK
CASE 6:
CALL main()
BREAK
DEFAULT:
PRINT "Invalid option. Please try again."
CALL admin()
BREAK
END SWITCH
END FUNCTION
FUNCTION tutor():
DECLARE tutorSessions AS Tutor
DECLARE tutor_Code[50] AS Character
DECLARE tutor_Password[50] AS Character
DECLARE program_Title[50] AS Character
DECLARE tutor_Name[50] AS Character
DECLARE rcdfound AS Integer
CALL getchar()
PRINT "Please enter tutor code : "
READ tutor_Code
tutor_Code[strcspn(tutor_Code, "\n")] = '\0'
pg. 13
C INDIVIDUAL ASSIGNMENT APU1F2209
IF rcdfound == 1 THEN
PRINT" Login Successful! "
DECLARE option AS Integer
PRINT "\
n============================================================="
PRINT "|Welcome to tutor menu |"
PRINT
"============================================================="
PRINT "|User options: |"
PRINT "| |"
PRINT "|1. Listings of sessions and students |"
PRINT "|2. Exit to main menu |"
PRINT
"============================================================="
PRINT "Please choose one option (1-2): "
READ option
IF option == 1 THEN
CALL tutorSession(tutor_Code)
ELSE IF option == 2 THEN
CALL main()
ELSE
PRINT "Invalid option. Please try again."
CALL tutor()
END IF
ELSE
PRINT "Wrong login credentials, please try again."
CALL tutor()
END IF
END FUNCTION
pg. 14
C INDIVIDUAL ASSIGNMENT APU1F2209
FUNCTION tutorSession(tutor_Code):
DECLARE listingTutor AS Tutor
fclose(fptr2)
system("pause")
CALL tutor()
END FUNCTION
FUNCTION student():
DECLARE studentSessions AS Student
DECLARE student_Name AS String
DECLARE tp_Number AS String
DECLARE student_Password AS String
DECLARE rcdfound AS Integer
pg. 15
C INDIVIDUAL ASSIGNMENT APU1F2209
IF rcdfound == 1 THEN
DECLARE option AS Integer
PRINT" Login Successful! "
PRINT "\
n=============================================================\n"
PRINT "|Welcome to student menu |\n"
PRINT "=============================================================\
n"
PRINT "|User options: |\n"
PRINT "| |\n"
PRINT "|1. Listings of sessions |\n"
PRINT "|2. Enrol into a session |\n"
PRINT "|3. Exit to main menu |\n"
PRINT "=============================================================\
n"
PRINT "Please choose one option (1-3): "
READ option
SWITCH option DO
CASE 1:
CALL studentSession(student_Name, tp_Number)
BREAK
CASE 2:
CALL enrolSession(student_Name, tp_Number)
BREAK
CASE 3:
CALL main()
BREAK
DEFAULT:
PRINT "Invalid option. Please try again."
CALL main()
BREAK
END SWITCH
ELSE // rcdfound == 0
PRINT "Wrong login credentials, please try again."
CALL main()
END IF
pg. 16
C INDIVIDUAL ASSIGNMENT APU1F2209
END FUNCTION
pg. 17
C INDIVIDUAL ASSIGNMENT APU1F2209
DECLARE fp AS File
fp = fopen("new_Session.txt", "r")
IF fp == NULL THEN
PRINT "File not available"
END IF
IF rcdfound == 1 THEN
WHILE fscanf(fp, "%[^/]/%[^/]/%[^/]/%[^/]/%[^/]/%[^\n]\n", &newSession.sessionCode,
&newSession.sessionTitle, &newSession.sessionDay, &newSession.startTime,
&newSession.sessionLocation, &newSession.tutorCode) != EOF DO
IF strcmp(session_Code, newSession.sessionCode) == 0 AND strcmp(session_Title,
newSession.sessionTitle) == 0 AND strcmp(tutor_Id, newSession.tutorCode) == 0 THEN
rcdfound1 = 1
BREAK
END IF
END WHILE
pg. 18
C INDIVIDUAL ASSIGNMENT APU1F2209
IF rcdfound1 == 1 THEN
WHILE fscanf(fptr2, "%[^/]/%[^/]/%[^/]/%[^/]/%[^/]/%[^/]/%[^\n]\n",
&studentEnrol.sessionCode, &studentEnrol.sessionTitle, &studentEnrol.tpNumber,
&studentEnrol.studentName, &studentEnrol.tutorCode, &studentEnrol.startTime,
&studentEnrol.sessionLocation) != EOF DO
IF strcmp(session_Code, studentEnrol.sessionCode) == 0 AND strcmp(session_Title,
studentEnrol.sessionTitle) == 0 AND strcmp(tp_Number, studentEnrol.tpNumber) == 0 AND
strcmp(student_Name, studentEnrol.studentName) == 0 AND strcmp(tutor_Id,
studentEnrol.tutorCode) == 0 THEN
Enrolled = 1
BREAK
END IF
END WHILE
IF Enrolled == 0 THEN
strcpy(studentEnrol.sessionCode, session_Code)
strcpy(studentEnrol.sessionTitle, session_Title)
strcpy(studentEnrol.tpNumber, tp_Number)
strcpy(studentEnrol.studentName, student_Name)
strcpy(studentEnrol.tutorCode, tutor_Id)
strcpy(studentEnrol.startTime, newSession.startTime)
strcpy(studentEnrol.sessionLocation, newSession.sessionLocation)
fprintf(fptr2, "%s/%s/%s/%s/%s/%s/%s\n", studentEnrol.sessionCode,
studentEnrol.sessionTitle, studentEnrol.tpNumber, studentEnrol.studentName,
studentEnrol.tutorCode, studentEnrol.startTime, studentEnrol.sessionLocation)
PRINT "The record has been added into the text file."
ELSE
PRINT "The student has existed in the text file."
END IF
ELSE
PRINT "The session does not exist."
END IF
ELSE
PRINT "The student info does not exist."
END IF
fclose(fptr2)
fclose(fp)
fclose(fptr1)
CALL main()
END FUNCTION
FUNCTION main():
DECLARE option AS Integer
PRINT
"============================================================="
pg. 19
C INDIVIDUAL ASSIGNMENT APU1F2209
IF option == 1 THEN
CALL admin()
ELSE IF option == 2 THEN
CALL tutor()
ELSE IF option == 3 THEN
CALL student()
ELSE IF option == 4 THEN
EXIT program
ELSE
PRINT "Invalid option. Please try again."
CALL main()
END IF
END FUNCTION
pg. 20
C INDIVIDUAL ASSIGNMENT APU1F2209
As the program's starting point, the main() function offers a menu-based user interface for navigating
among the various user roles in the Programming Cafe Sessions Management System. When the
function is run, a welcome message appears and the user is given the choice between the options
"Admin," "Tutor," "Student," or "Exit." The user is asked to select a user type by keying in a number
between 1 and 4. The programme branches to the appropriate function, such as admin(), tutor(),
student(), or exit(0), depending on the choice that has been chosen.
pg. 21
C INDIVIDUAL ASSIGNMENT APU1F2209
In the Programming Cafe Sessions Management System, the administrative menu is represented by the
admin() function. When called, it displays a menu with various options for administrative chores for
the user. The user is required to enter a number to select an option. The function executes the
appropriate task using a switch statement depending on the option that was chosen. These activities
include adding a new session, registering a new student, adding a new tutor, enrolling a student in a
session, and listing all the sessions with the participating students. The option to go back to the main
menu is also available. The function recursively executes itself to allow for a valid option if the user
selects an invalid option, and an error notice is presented.
pg. 22
C INDIVIDUAL ASSIGNMENT APU1F2209
The Register Tutor option prompts the tutorRegistration() function to register a tutor with the
management system. The administrator is prompted to enter the tutor's information, including their
tutor code, tutor name, tutor password, and the title of the programming class. The "tutor_Data.txt" file
is then opened by the function to determine whether the tutor code or programming class title has
already been registered as a tutor or is a duplicate of an existing class. If the tutor code or class title
cannot be located in the file, the registration process is carried out by the function. The tutor code, tutor
password, programming class title, and tutor name are all stored in a new record that is created for
them in the format that is requested. After that, this data is added to the "tutor_Data.txt" file
pg. 23
C INDIVIDUAL ASSIGNMENT APU1F2209
On the other hand, the function alerts the administrator that the record already exists if the tutor code
or programming class title is already present in the file, preventing multiple registrations. The output
“The record has existed in the text file!” once the system finds a matching record in the tutor_data.txt
file. In conclusion, by assuring the uniqueness of tutor codes and programming title class, the
tutorRegistration() function simplifies the registration of tutors. Within the APU management system,
it enables the administrator to maintain and update the list of registered tutors without the risk of
redundancies.
pg. 24
C INDIVIDUAL ASSIGNMENT APU1F2209
A new session is added to the system using the newSession() function. The function asks the user to
submit information such as the session title, session code, session day, start time, location, and tutor
code after it has been executed. By reading information from the "tutor_Data.txt" file, it then goes on to
verify the accuracy of the tutor code and session title. The function then determines whether the session
code, session title, and tutor code combination already exist in the "new_Session.txt" file if a matching
tutor code and session title are discovered. A new session record is constructed using the given
information if the combination is unsuccessful and is then added to the "new_Session.txt" file. A
confirmation message appears when the new session has been added successfully
pg. 25
C INDIVIDUAL ASSIGNMENT APU1F2209
Error messages are displayed appropriately if the tutor code or session title cannot be located. The
function then closes all open file references before returning to the administration menu. The example
shown above shows an output “The session and tutor code does not exist”. This is because previously in
the tutor code, user has not registered any tutor code by T07 that is associated with T Programming.
Therefore the output is an error message.
pg. 26
C INDIVIDUAL ASSIGNMENT APU1F2209
The studentRegistration() function allows users to register a student into the system. When the function
is used, a prompt asking for the student's name, TP number, and password appears. The next step is to
read information from the "student_Data.txt" file to verify the TP number's uniqueness. Then a new
student record is created using the information provided and is added to the "student_Data.txt" file. A
confirmation message appears after a successful registration. The programme then returns to the
administration menu after closing the file pointer. If there is a duplicate student record, it will return
“the student has existed in the text file.”
pg. 27
C INDIVIDUAL ASSIGNMENT APU1F2209
This error message is shown if the system discovered a matched TP number, which would suggest that
the student is already registered. If there is a duplicate student record, it will return “the student has
existed in the text file.”
pg. 28
C INDIVIDUAL ASSIGNMENT APU1F2209
The process of enrolling students in a session is handled by the studentEnrolment() function. The
function asks for the student’s name, TP number, tutor ID, session code, and session title when it is
called. Then, by reading information from the "student_Data.txt" file, it verifies that the entered TP
number is valid. If a match is discovered, proving that the student is registered, the function continues
by reading the "new_Session.txt" file to determine whether the session is open. The function then
determines whether the student is already enrolled in that session by reading the
"student_Enrolment.txt" file if a session matching the required code, title, and tutor ID is discovered. If
the student is not registered, a new record is made using the given information and added to the
"student_Enrolment.txt" file. When enrollment is successful, a success message is shown. It shows “The
record has been added into the text file.”
pg. 29
C INDIVIDUAL ASSIGNMENT APU1F2209
A suitable error notice is given, in the form of “The student has existed in the text file, nevertheless, if
the student is already registered for the session or if the session or student information is missing. The
program then returns to the administration menu after closing the file pointers.
pg. 30
C INDIVIDUAL ASSIGNMENT APU1F2209
A list of session enrollments is shown through the listings() function. The "student_Enrolment.txt" file is
opened for reading when the function is called. The next step is to print a table that shows output with
the following headers: "Session code," "Session title," "TP number," "Student Name," "Tutor code,"
"Start time," and "Session location." Using fscanf(), the function reads each line of the file and extracts
the values for each field. After that, it uses printf() to format and print the extracted data in a tabular
format. The loop runs till the file's conclusion. The listings() function's output shows a formatted list of
session enrollments, where each row corresponds to a different enrollment record. It is simpler to read
and comprehend the data because the values for each field are arranged according to the headers they
are assigned to. The function presents this data according to the information that has been entered into
the "student_Enrolment.txt" file. The program then calls the admin() function to return to the
administration menu after printing the list and closing the file.
pg. 31
C INDIVIDUAL ASSIGNMENT APU1F2209
When the tutor() function is called, it will lead to the login of the tutor menu. When executed, the
function prompts the user to enter their tutor code and password. It then reads the "tutor_Data.txt" file to
check if login credentials are met, then the “Welcome to tutor menu page” will be shown, and the user is
shown 2 options to choose from. They can choose option 1 to view listings of sessions and students or
option 2 to exit to the main menu. Once the user selects option 1, the tutorSession() function is called,
passing the tutor's code as a parameter. This function is responsible for displaying session and student
listings that are specific to the tutor. If option 2 is selected, main() function shall be called which leads
back to the main page.
pg. 32
C INDIVIDUAL ASSIGNMENT APU1F2209
If the login credential of the tutor code or password are incorrect, an error messaged would be
displayed, tutor() function is called again to enter the input again. The error message “Wrong login
credentials, please try again” will be displayed.
pg. 33
C INDIVIDUAL ASSIGNMENT APU1F2209
When the option 1 is selected in the tutor menu, the tutorSession() function is responsible for displaying
the sessions and students listings specific to a tutor. It takes the tutor's code as a parameter to filter the
listings and show only the sessions associated with that tutor, therefore, only one tutor code is present.
When executed, the function opens the "student_Enrolment.txt" file to read the session and student
records. If the file is not available, an error message is displayed. The function then displays a table
columns and rows for inputting the session code, session title, TP number, student name, tutor code,
start time, and session location. This table provides a clear structure for presenting the information.
Using a loop, the function reads each line of the file and stores the corresponding data into the
listingTutor structure. If the tutor code in the current line matches the provided tutor code, the session
details are printed in the in the table as shown above. In this example, it shows the Sessions related to
the tutor code “T01”. This process continues until the end of the file is reached (EOF). Therefore, all
sessions associated with T01 are displayed in the table. Finally, the file is closed, and the system pauses
to allow the tutor to view the information. After pressing any key, the main() function is called to return
to the main menu.
pg. 34
C INDIVIDUAL ASSIGNMENT APU1F2209
The student menu is selected when user entered number 3 in the main menu. It will then run the
student() function which is responsible for handling the menu and actions available to students. It
prompts the student to enter their name, TP number, and password for login purposes. From the
example above we can see the login credentials of the student Sam, along with his TP number,
TP064294 and password, Sam02. After obtaining the information, the function opens the
"student_Data.txt" file to read the student Sam is in the records. If a match is found, the login is
considered successful. Once Sam has managed to login, a student menu is displayed. The menu
provides three options which are, Listings of sessions, Enrol into a session, and Exit to main menu.
The user is required to choose an option by entering a number from 1-3. Depending on the chosen
option, a corresponding function will be called to perform the requested action.
pg. 35
C INDIVIDUAL ASSIGNMENT APU1F2209
If the file is not available, an error message is displayed. The function reads the file and checks if the
TP number entered by the student matches any of the TP numbers in the file. The error message shows
that the user has entered the wrong login credentials, therefore they are prompted to try again.
pg. 36
C INDIVIDUAL ASSIGNMENT APU1F2209
The listings of sessions are responsible for showing the sessions in which a specific student is enrolled
in. In the above example, when user entered 1 it will show the sessions that is specific to the student
Sam, as Sam was logged into the student menu. It takes the student's name and TP number as
parameters then opens the "student_Enrolment.txt" file to read and to access the session enrollment
records. If the file is not available, an error message is displayed. If a match is found it will showcase a
table header that is printed to provide a clear structure for the session information. The header includes
column labels such as "Session code," "Session title," "TP number," "Student Name," "Tutor code,"
"Start time," and "Session location." The above example shows 3 rows of information which means
that Sam is enrolled in 3 sessions. The information is displayed neatly with alignments to its header.
The program then pauses for users to review the sessions thoroughly, then once any key is pressed,
function menu() will be called and it will return to the main page.
pg. 37
C INDIVIDUAL ASSIGNMENT APU1F2209
In the student menu, users are given an option to enrol themselves in a session. Once they have
selected this option, a function called enrolSession() is responsible for enrolling a student into a
session. It takes the student’s name and TP number as parameters and requests the user to enter session
details such as session code, session title, and tutor ID. As shown above, Ben has successfully logged
into the student menu. As the options are went through, Ben decided to enrol himself into a session. It
works by opening the “new_Session.txt” file in read mode to access the available session records. If
the file is not available, an error message is displayed. Similarly, it opens the “student_Data.txt” and
“student_Enrolment.txt” files to retrieve student information and check existing enrolments,
respectively. The function then scans if the student’s TP number exists in the “student_Data.txt” file by
scheming through each line and comparing the TP number. If a match is found, the rcdfound flag is set
to 1. Once TP number is found, the function proceeds to check if the provided session details match
any available sessions in the “new_Session.txt” file. It compares the session code, session title, and
tutor ID. If a match is found, the rcdfound1 flag is set to 1. Next, the function scans if the student was
already enrolled in the session by looking through the “student_Enrolment.txt” file. It compares the
session code, session title, TP number, student name, and tutor ID. If a match is found, the Enrolled
pg. 38
C INDIVIDUAL ASSIGNMENT APU1F2209
flag is set to 1. If the student is not already enrolled in the session (Enrolled == 0), the function creates
a new enrolment record using the provided session details and student information. The session code,
session title, TP number, student name, tutor code, start time, and session location are copied to the
studentEnrol structure. The ennrolment record is then appended to the “student_Enrolment.txt” file
using fprintf(). Then a message is displayed to indicate the outcome of the ennrolment process. If the
student is successfully enrolled, a success message is shown.
Students can check to see if they are enrolled into the session logging into the student menu again and
check their listings of sessions. The above example shows that Ben has successfully been added into
Java Programming session.
pg. 39
C INDIVIDUAL ASSIGNMENT APU1F2209
The function then scans if the student’s TP number exists in the “student_Data.txt” file by scheming
through each line and comparing the TP number. If the student or session information is not found,
corresponding error messages are displayed. The output displays “The session does not exist.”
pg. 40
C INDIVIDUAL ASSIGNMENT APU1F2209
5.0 CONCLUSION
In conclusion, this program allows users the basic functionality of managing tutor, student, and session
information. It allows for the registration of tutors and students, creation of new sessions, enrolment of
students in sessions, and displaying session listings. The program uses text files to store the data
related to tutors, students, sessions, and student enrolments. It also has a login function at the tutor and
student menu to further enhance the management system and made it more secure. Several important
functions found in the code are tutorRegistration(), newSession(), studentRegistration(),
studentEnrolment(), and listings(). They all played a role in managing the APU café management and
providing a systematic program that operates tutoring and educational system. It is essentially allowing
administrators, tutors, and students on the platform to perform the various operations the system has to
offer.
pg. 41
C INDIVIDUAL ASSIGNMENT APU1F2209
6.0 REFERENCES
1. Edit and run code in Visual Studio Code. (2021, November 3).
https://code.visualstudio.com/docs/introvideos/codeediting
YouTube. https://www.youtube.com/watch?v=KJgsSFOSQv0
pg. 42