#include #include using namespace std; struct item { string description; int upc; int price; item(string d, int u, int p) { description = d; upc = u; price = p; } void print() { cout << description << ", upc=" << upc << ", " << price << "c\n"; } }; struct Link { item * data; Link * next; Link(item * i, Link * n) { data = i; next = n; } }; int main() { Link * List = NULL; while (true) { string desc; int up, pr; cout << "Item: "; cin >> desc; if (desc == "stop") break; cin >> up >> pr; item * i = new item(desc, up, pr); List = new Link(i, List); } cout << "\n"; cout << "Inventory:\n"; Link * ptr = List; while (ptr != NULL) { ptr->data->print(); ptr = ptr->next; } cout << "End of list\n"; int total = 0; while (true) { cout << "Item and quantity? "; string des; int qty; cin >> des; if (des == "stop") break; cin >> qty; Link * ptr = List; while (ptr != NULL) { if (ptr->data->description == des) { total += qty * ptr->data->price; break; } ptr = ptr->next; } } cout << "Total price = " << total << "c\n"; while (List != NULL) { delete List->data; Link * follower = List->next; delete List; List = follower; } cout << "All data recycled\n"; }