CNG213-Assignment-2022-2023 - Spring
CNG213-Assignment-2022-2023 - Spring
This assignment aims to help you practice linked list data structure and basic linked list
operations. Your main task in this assignment is to write a C program to create a simple
application that will allow you to manage your travel details. This application will mainly keep
your travel details in a simple text file but when loaded into your application, your application will
keep your travel details in an internal Linked List. For each travel, your application will store the
following details: a unique identification number, the name of the country, the departure date,
the return date, and the type of travel (Business, Holiday, Education).
When you start the application, it will read your travels from an external text file
(travelArchive.txt), create a linked list and then populate this list with the travels stored in that file.
This application will then provide some operations for you to manage your travels. When you exit
from the application, the application will overwrite the external file with the latest version of the
list to include the latest travels in your application. Therefore, the TAS application needs to
support the following operations.
• Reading your travels from an external file and initializing your travel lists: The application will
start by reading the travels from an external text file called travelArchive.txt. The
travelArchive.txt file will include the details of the travels that you have, including uniqueID,
countryName, departureDate, returnDate, and travelType separated by a semicolon. An
example file (travelArchive.txt) is shown below that contains four travels:
1;Turkey;22/02/2022;02/03/2022;Business
2;Italy;15/07/2022;28/07/2022;Holiday
3;Cyprus;15/09/2022;27/01/2023;Education
4;Turkey;26/02/2023;01/03/2022;Holiday
The application will then internally store these travels in a linked list. Please note that you
cannot make any assumptions about the number of travels you have in your list and there is
no upper limit for the number of travels. In your internal representation, you will need to
decide about the structure of your linked list based on the txt file given above.
• Adding a new travel: After the initialization of the application with the external file, you may
want to add a new travel to your archive. In this case, the application will ask you to enter
the travel details, including the unique identification number, the name of the country, the
departure date, the return date, and the type of travel (Business, Holiday, Education).
Page 1 of 6
• Deleting a travel: This application will allow you to select a specific travel by using its unique
id from the list and delete it.
• Printing your travels: This application will allow you to print the travels that you manage in
your application. Deleted travels should not be displayed.
• Searching for travel: This application will allow you to search for a travel by using the following
details: country name or travel type. More than one travel can be listed after searching. You
can make use of external libraries in C, such as string.h library.
• Create a special list: This application will also allow you to create a special list. The user will
give the travel type, and a new list will be created and the travel details of that special travel
type will be stored in an external text file. The file name should be created automatically with
the name of the travel type (could be Business, Holiday, Education) and every time a new list
is created, a new file should be created, such as “Business.txt”, “Holiday.txt” or
“Education.txt”. Your application does not need to be smart to check if the list was already
created or not.
• Overwriting the external file: When the application is closed, the external file
(travelArchive.txt) should be overwritten with the latest version of the list.
Programming Requirements:
When you write this application, you need to consider the data structure(s) that will be
necessary. Therefore, it is recommended that you implement your basic linked list operations first
(add/delete/search/print, etc). By using these basic operations on linked lists, you can
implement other required operations. You also need to define and use a structure for departure
and return dates. To achieve these steps, you need to have the following functions. Please strictly
follow the requirements of the functions given below! In addition to these functions, you can
write some helper/auxiliary functions.
Page 2 of 6
search keys.
createSpecialList To create a special list with the A list of travels -
travel details provided. and travel type
Overwrite To overwrite the external files with A list of travels -
the latest versions of the list.
Grading:
Your program will be graded as follows:
Grading Point Mark (out of 100)
Structures to represent a list of emails and date-time 5
Main function to control and coordinate the commands 15
initializeTravels 15
addTravel 10
deleteTravel 5
printTravels 5
searchTravels 15
createSpecialList 15
Overwrite 15
Important Notes:
• Remember to have good programming style (Appropriate comments, variable names,
formulation of selection statements and loops, reusability, extensibility etc.). Each of the items
above will include10% for good programming style.
• Read rules regarding to assignments from the Syllabus carefully.
• If your code does not compile due to syntax errors, you will automatically get zero.
• If your code includes global variables, you will automatically get zero.
-----MENU---------------------------------------
1. Add Travel
2. Delete Travel
3. Print Travels
4. Search Travels
5. Create Special List
6. Exit
Page 3 of 6
-----MENU----------------------------------------
1. Add Travel
2. Delete Travel
3. Print Travels
4. Search Travels
5. Create Special List
6. Exit
-----MENU----------------------------------------
1. Add Travel
2. Delete Travel
3. Print Travels
4. Search Travels
5. Create Special List
6. Exit
-----MENU----------------------------------------
1. Add Travel
2. Delete Travel
3. Print Travels
4. Search Travels
5. Create Special List
6. Exit
Page 4 of 6
-----MENU----------------------------------------
1. Add Travel
2. Delete Travel
3. Print Travels
4. Search Travels
5. Create Special List
6. Exit
-----MENU----------------------------------------
1. Add Travel
2. Delete Travel
3. Print Travels
4. Search Travels
5. Create Special List
6. Exit
-----MENU----------------------------------------
1. Add Travel
2. Delete Travel
3. Print Travels
4. Search Travels
5. Create Special List
6. Exit
The special list for Business type travels has been created and stored in the
file: Business.txt!
Page 5 of 6
-----MENU----------------------------------------
1. Add Travel
2. Delete Travel
3. Print Travels
4. Search Travels
5. Create Special List
6. Exit
Page 6 of 6