SDP Assignment1 (1)
SDP Assignment1 (1)
md 2025-03-31
ID: e20230409
Group: I2-GTR
Assignment 2's homework: Read student data of I2 AMS-GIC-GTR from file student list and store in Linked list.
Test functions: add end, add begin, display all, delete begin, search. Student list file is attached below.
.Input
#include <iostream>
#include <string>
using namespace std;
int main() {
List* listAMS = createEmptyList();
List* listGIC = createEmptyList();
List* listGTR = createEmptyList();
int choice;
do {
cout << "\nMenu:\n";
cout << "1. Add Student\n";
cout << "2. Display Students\n";
cout << "3. Search Student\n";
cout << "4. Delete First Student\n";
cout << "5. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
if (choice == 1) {
int id;
2/4
SDP Assognment.md 2025-03-31
string name;
int listChoice;
cout << "Enter Student ID: ";
cin >> id;
cout << "Enter Student Name: ";
cin.ignore();
getline(cin, name);
if (listChoice == 1) displayMyList(listAMS);
else if (listChoice == 2) displayMyList(listGIC);
else if (listChoice == 3) displayMyList(listGTR);
else cout << "Invalid choice!\n";
}
else if (choice == 3) {
string name;
int listChoice;
cout << "Enter Student Name to Search: ";
cin.ignore();
getline(cin, name);
if (listChoice == 1) deleteBegin(listAMS);
else if (listChoice == 2) deleteBegin(listGIC);
else if (listChoice == 3) deleteBegin(listGTR);
else cout << "Invalid choice!\n";
}
} while (choice != 5);
3/4
SDP Assognment.md 2025-03-31
return 0;
}
.Output
Menu:
1. Add Student
2. Display Students
3. Search Student
4. Delete First Student
5. Exit
Enter your choice: 1
Enter Student ID: 101
Enter Student Name: Jonh
Select List: 1. AMS 2. GIC 3. GTR: 3
Menu:
1. Add Student
2. Display Students
3. Search Student
4. Delete First Student
5. Exit
Enter your choice: 1
Enter Student ID: 102
Enter Student Name: Steven
Select List: 1. AMS 2. GIC 3. GTR: 3
Menu:
1. Add Student
2. Display Students
3. Search Student
4. Delete First Student
5. Exit
Enter your choice: 1
Enter Student ID: 103
Enter Student Name: Jack
Select List: 1. AMS 2. GIC 3. GTR: 3
Menu:
1. Add Student
2. Display Students
3. Search Student
4. Delete First Student
5. Exit
4/4