Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this assignment, you are going to write an ordered linked list to implement a grocery list. You will ask the user for information and

For this assignment, you are going to write an ordered linked list to implement a grocery list. You will ask the user for information and modify the list as the user indicates. All of the information will be written to a file. Just as in the first program, you are to check to see if the file exists. If it does, open the file and populate the list. When the program terminates, print the information to a file. Call the file grocerylist.txt. The first entry in the list is to be the number in the list. You will modify the Node class that you wrote in the last program. You will create a structure that contains the main data and the Node class will contain a variable of that structure and the link. You will write an ordered link list class that will insert, delete, traverse, and retrieve items from the list. The list will be ordered on the UPC code. You will not enter duplicate items. If the item already exists, then you need to indicate that to the user and not enter it in the list. Structure data: UPC code number of the item Item description description of item that must be able to include spaces Quantity number of item to purchase Cost cost per item Aisle number of aisle at store Node class data: Structure will be a declaration of the structure defined above must be private to the class Link pointer to next item in the list Node class member functions Default constructor Constructor that takes UPC, item, quantity, cost, and aisle Mutator function to set next pointer Accessor function to return next pointer Accessor function to return UPC code Accessor function to return complete structure compare_item function that will compare a given item against the one in the class process_data function that will calculate and return the total cost for this item. Total cost = cost * quantity. Linked list class data head pointer points to first Node in list tail pointer points to last Node in list count keeps track of number of Nodes in list Linked list class functions Any needed constructors Insert node Delete node Traverse list Retrieve node Check for empty Return number in list Note: This is an ORDERED list. It will be ordered by UPC number. Note: Remember that a linked list is created in static (automatic memory) and a Node is in dynamic memory. Requirements for main: In the main program, you are to declare the linked list when the execution of your program begins. You will present a menu to the user to ask if the user wants to 1) Add a grocery item 2) Delete an item 3) Retrieve an item 4) Traverse the list forwards and print out all of the items or 5) exit the program. When the user selects 1, the program should ask for the UPC code, item description, quantity, and aisle. When the user selects 2, the program should ask for the UPC code to be deleted. The program should ask the user to confirm that item is to be deleted. When the user selects 3, the program should ask for the UPC code to be retrieved. When the user selects 4, all of the nodes should be traversed in the list and printed. The total cost for each item should be calculated. The items should be printed in the linked list traverse function by using the accessor function for the entire structure. When the user selects 5, the program should end and write the current list to the file. Sample input: 1 Enter UPC code: Enter description: Enter quantity: Enter cost: Enter aisle: 2 Enter item to delete: Show item to delete Confirm delete (y/n)? 3 Enter UPC code: Show information 4 print out list in order by UPC code. Should include total cost 5 Exit program and write list to file. Sample output when 4 is selected. 1234 Butter 1 $3.00 Aisle 10 1235 Sour Cream 2 $1.25 Aisle 10 1236 Bread 5 $1.40 Aisle 22 Here's my node class that I previously made. class Node { private: string title; string author; string date_read;

Node *next;

public: Node();

Node(string t,string a,string d);

void set_pointer(Node *ptr) { next=ptr; }

Node *get_pointer() { return next; }

bool title_compare(string t);

string get_title(void);

void output_data(void); };

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How Do I Use A Database Research Tools You Can Use

Authors: Laura La Bella

1st Edition

1622753763, 978-1622753765

More Books

Students also viewed these Databases questions

Question

How will the members be held accountable?

Answered: 1 week ago

Question

a. Do team members trust each other?

Answered: 1 week ago