Question: Guys I've been working on it for a week and I ' m going crazy.!!! Today is the last day of homework, can you help

Guys I've been working on it for a week and I'm going crazy.!!!
Today is the last day of homework, can you help me? C++
My code;
#include
#include
using namespace std;
// Function declaration
void menu(int &input); // Pass input variable by reference
int main(){
// Variable declarations
int is_LL_created =0, input =0, LL_size =0, ID_size =0, Name_size =0, GPA_size =0;
int* ID = nullptr;
float* GPA = nullptr;
string* Name = nullptr;
// Main loop for menu-driven interaction
while (true){
// Display menu and get user input
menu(input); // Pass input variable by reference
// Handle user input
if (input ==1 && is_LL_created ==0){
// Create linked list
cout << "Enter size of linked list: ";
cin >> LL_size;
ID = new int[LL_size];
GPA = new float[LL_size];
Name = new string[LL_size];
is_LL_created =1;
cout << "Linked list is created.
";
} else if (input ==1 && is_LL_created ==1){
// Linked list already created
cout << "Linked list is already created.
";
} else if (input ==2 && is_LL_created ==1){
// Add node to the linked list
if (ID_size < LL_size){
cout << "Please enter ID: ";
cin >> ID[ID_size];
cout << "Please enter GPA: ";
cin >> GPA[GPA_size];
cin.ignore();
cout << "Please enter Name: ";
getline(cin, Name[Name_size]);
ID_size++;
GPA_size++;
Name_size++;
cout << "Node added successfully.
";
} else {
cout << "Linked list is full. Cannot add more nodes.
";
}
} else if (input ==3 && is_LL_created ==1){
// Delete node from the linked list (not implemented)
cout << "Delete functionality not implemented yet.
";
} else if (input ==4 && is_LL_created ==1){
// Display linked list (not implemented)
cout << "Display functionality not implemented yet.
";
} else if (input ==8){// Check for Exit option
// Exit the program
cout << "Program exit.
";
break; // Exit the loop if Exit option is selected
} else {
// Invalid command or linked list not created
cout << "Invalid command or linked list not created.
";
}
}
// Deallocate memory before exiting
delete[] ID;
delete[] GPA;
delete[] Name;
return 0;
}
// Function definition for displaying menu
void menu(int &input){// Receive input variable by reference
cout << "Enter command
"
<<"1. Create
"
<<"2. Add
"
<<"3. Delete
"
<<"4. Display
"
<<"5. Modify
"
<<"6. Purge entire list
"
<<"7. Search for node
"
<<"8. Exit
";
cin >> input;
}
2. Add a node (node contents of your choice):
a) When the List is empty
b) In the beginning of the List
c) In the end of the List
d) Somewhere between the beginning and the end of the List.
e) When the LL is not created
f) when a duplicate record is found
The ADD algorithm is to determine where the new node is to be placed
in the List.
The user is not asked where the new node should be
inserted.
3. Delete anode:
a) When the List is empty
b) From the beginning of the List
c) From the end of the List
d) From somewhere between the beginning and the end of the List.
e) When the LL is not created
f) show what happens when an attempt is made to delete a node which
is not in the list
The DELTE algorithm is to determine where the targeted
node is placed in the List.
The user is not asked about the location of the targeted
node.
4. Search for a node and display its contents.
The Search is done based on a key field from the node (i.e a name, or
an ID)
The Search algorithm is to locate the targeted node and to display it.
The user is not asked about the location of the targeted
node.
Show what happens when and where the target is found and
when it is not found
5. Modify a node.
The user is to enter a key field from the node (i.e a name, or an ID)
The Search algorithm is to search for the targeted node from the
beginning of the List.
Address what happens if an attempt is made to search for a record
before creating the LL
Display the node before and after modification.
6. Display the Entire Linked List.
The display function is to display the list from the front to end and
Address what happens if an attempt is made to search for a record
before creating the LL
7. purge the LL

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!