Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a menu-driven C++ program to track your favorite movies in C++ string usin

ID: 3592717 • Letter: W

Question

Write a menu-driven C++ program to track your favorite movies in C++ string using Linked Lists.

Sample Output:

Requirements:

- Allow for movie titles up to 30 characters in length.
- Do case-independent sorting, but do not convert the case of movie titles when they are entered using cin.
- You decide upon your rating system -- can be any data type.
- Use a linked list to store the movie information, initially empty, but with three nodes added before the main loop starts.
- The output table should have nicely-spaced column headings with sequence numbers.
- Use sequence numbers for the update and remove options.
- If an out-of-range sequence number is entered for either the remove or update options, either ignore it or output a warning -- your choice.
- Output blank lines to separate blocks of text as modeled in the sample output above.


Limitations:

We cannot add nodes, because nodes have to have been already declared in order to be in the linked list.

So do this -- start with 3 or more nodes, initialized to generic movie titles (like movie1). Put them all in the list before starting the menu loop. Once a node is removed, it's gone!

Keeping Track Of The Number Of Nodes:

Did you notice the "Which movie to update [1-3]:" prompt? It's not as easy as it looks! What if a node has been removed? Then it's "[1-2]". You'll need a way to keep track of the number of nodes in your list, and a way to put that number in the update and remove prompts. It's not too hard if you think about it and plan it out.

Do not save the sequence number as an attribute of the movie objects!

---------------------------------------------------------------------

Been trying to work on this code for awhile and my code is a complete mess, having trouble understanding linked lists, any help is highly appreciated.

Explanation / Answer

#include #include #include /* Link list node */ struct Node { int data; struct Node* next; }; /* Given a reference (pointer to pointer) to the head of a list and an int, push a new node on the front of the list. */ void push(struct Node** head_ref, int new_data) { /* allocate node */ struct Node* new_node = (struct Node*) malloc(sizeof(struct Node)); /* put in the data */ new_node->data = new_data; /* link the old list off the new node */ new_node->next = (*head_ref); /* move the head to point to the new node */ (*head_ref) = new_node; } /* Takes head pointer of the linked list and index as arguments and return data at index*/ int GetNth(struct Node* head, int index) { struct Node* current = head; int count = 0; /* the index of the node we're currently looking at */ while (current != NULL) { if (count == index) return(current->data); count++; current = current->next; } /* if we get to this line, the caller was asking for a non-existent element so we assert fail */ assert(0); } /* Drier program to test above function*/ int main() { /* Start with the empty list */ struct Node* head = NULL; /* Use push() to construct below list 1->12->1->4->1 */ push(&head, 1); push(&head, 4); push(&head, 1); push(&head, 12); push(&head, 1); /* Check the count function */ printf("Element at index 3 is %d", GetNth(head, 3)); getchar(); }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote