Answered step by step
Verified Expert Solution
Question
1 Approved Answer
can you change the following code according to the instruction and units and finish the rest please. #include #include #include #include using namespace std; struct
can you change the following code according to the instruction and units and finish the rest please.
#include8. Then write a main driver program that will demonstrate all the capabilities of your ADTs as follows - - First, print a Welcome message for the demonstration of your ADTs - you can decide what the message says but it should include your full name(s). - Second, create the following twenty (20) Krone objects in a Currency array to be used in the program. 1. Kr57.12 2. Kr23.44 3. Kr87.43 4. Kr 68.99 5. Kr111.22 6. Kr44.55 7. Kr77.77 8. Kr18.36 9. Kr543.21 10. Kr20.21 11. Kr345.67 12. Kr36.18 13. Kr 48.48 14. Kr 101.00 15. Kr11.00 16. Kr 21.00 17. Kr 51.00 18. Kr1.00 19. Kr251.00 20. Kr 151.00 - Then, create one each of SinglyLinkedList, Stack and Queue objects. - For the linked list, perform the following operations in order - A. Add the first seven (7) objects from the array into the linked list in order such that they end up in the reverse order in the linked list, i.e. the seventh element as first node and first element as seventh node. If it is easier, you are allowed to insert copies of the objects. B. Search for Kr87.43 followed by Kr44.56 - print the results of each. C. Remove the node containing Kr111.22 followed by the node at index 2. D. Print the contents of the list. E. Then add the next four (4) objects (\#9 thru 12) such that their index in the linked list is calculated as (index in array %5 5). F. Remove two (2) objects at indexes (countCurrency % 6) and (countCurrency / 7 ) in that order. G. Print the contents of the list. - For the stack, perform the following operations in order - A. Push seven (7) objects starting from the array index 13 onwards to the stack. B. Peek the top of the stack - print the result. C. Perform three (3) pops in succession. D. Print the contents of the stack. E. Push five (5) more objects from the start of the objects array to the stack. F. Pop twice in succession. G. Print the contents of the stack. - For the queue, perform the following operations in order - A. Enqueue the seven (7) objects at odd indexes starting from index 5 in the array. B. Peek the front and end of the queue - print the results. C. Perform two (2) dequeues in succession. D. Print the contents of the queue. E. Enqueue five (5) more objects from the index 10 in the array. F. Dequeue three times in succession. G. Print the contents of the queue. - End the program with a leaving message of your choice. Remember to clean up before the program ends. - Restrict all your input / output to the main driver program only, except for the existing screen print inside the Currency print methods. 8. Then write a main driver program that will demonstrate all the capabilities of your ADTs as follows - - First, print a Welcome message for the demonstration of your ADTs - you can decide what the message says but it should include your full name(s). - Second, create the following twenty (20) Krone objects in a Currency array to be used in the program. 1. Kr57.12 2. Kr23.44 3. Kr87.43 4. Kr 68.99 5. Kr111.22 6. Kr44.55 7. Kr77.77 8. Kr18.36 9. Kr543.21 10. Kr20.21 11. Kr345.67 12. Kr36.18 13. Kr 48.48 14. Kr 101.00 15. Kr11.00 16. Kr 21.00 17. Kr 51.00 18. Kr1.00 19. Kr251.00 20. Kr 151.00 - Then, create one each of SinglyLinkedList, Stack and Queue objects. - For the linked list, perform the following operations in order - A. Add the first seven (7) objects from the array into the linked list in order such that they end up in the reverse order in the linked list, i.e. the seventh element as first node and first element as seventh node. If it is easier, you are allowed to insert copies of the objects. B. Search for Kr87.43 followed by Kr44.56 - print the results of each. C. Remove the node containing Kr111.22 followed by the node at index 2. D. Print the contents of the list. E. Then add the next four (4) objects (\#9 thru 12) such that their index in the linked list is calculated as (index in array %5 5). F. Remove two (2) objects at indexes (countCurrency % 6) and (countCurrency / 7 ) in that order. G. Print the contents of the list. - For the stack, perform the following operations in order - A. Push seven (7) objects starting from the array index 13 onwards to the stack. B. Peek the top of the stack - print the result. C. Perform three (3) pops in succession. D. Print the contents of the stack. E. Push five (5) more objects from the start of the objects array to the stack. F. Pop twice in succession. G. Print the contents of the stack. - For the queue, perform the following operations in order - A. Enqueue the seven (7) objects at odd indexes starting from index 5 in the array. B. Peek the front and end of the queue - print the results. C. Perform two (2) dequeues in succession. D. Print the contents of the queue. E. Enqueue five (5) more objects from the index 10 in the array. F. Dequeue three times in succession. G. Print the contents of the queue. - End the program with a leaving message of your choice. Remember to clean up before the program ends. - Restrict all your input / output to the main driver program only, except for the existing screen print inside the Currency print methods#include #include #include using namespace std; struct LinkNode { void *data; LinkNode* next; }; LinkNode* head; class Slinklist { private: int counts; LinkNode* start; LinkNode* end; public: Slinklist(){ head = NULL; } //setter for LinkList class void set_count(int count) { this->counts = count; } void set_start(LinkNode* start) { this->start = start; } void set_end(LinkNode* end) { this->end = end; } int get_count() { return this->counts; } LinkNode* get_start() { return this->start; } LinkNode* get_end() { return this->end; } void insert(void* data) { LinkNode* node; node = new LinkNode(); node->data = data; node->next = NULL; if (head == NULL) head = node; else { LinkNode *a = head; while (a->next != NULL) { a = a->next; } a->next = node; } } void Remove(void *data) { int n = 0; int n1 = 0; LinkNode *p = head; LinkNode *p1 = head; if (p== NULL) { cout data == *(int *)data) break; prev = p; p = p->next; } prev->next = p->next; free(p); cout data next; } } } void search(void *data) { int check = 0; LinkNode *p = head; if (p == NULL) cout data == *(int *)data) { check++; goto show; } p = p->next; } show: if (check == 0) cout data; } } void count() { LinkNode *p = head; int count = 0; while (p != NULL) { count++; p = p->next; } cout data == data) { p->data = newData; check++; } p = p->next; } if (check == 0) cout data = data; stack->next = NULL; head = stack; } else { stack->data = data; stack->next = head; head = stack; } cout data; } void pop(){ cout data next; } void peek(){ cout data; } void Empty() { LinkNode* temp = head; LinkNode* next; while (temp!=NULL) { next = temp->next; free(temp); temp = next; } cout data = data; queue->next = NULL; if (head == NULL) head = queue; else { LinkNode* temp = head; while (temp->next!=NULL) { temp = temp->next; } temp->next = queue; } cout data; head = head->next; } } void peekFront(){ if (head == NULL) cout data; } } void peekRear(){ if (head == NULL) cout next!=NULL) { temp = temp->next; } cout data; } } void Empty(){ LinkNode* temp = head; LinkNode* next; while (temp != NULL) { next = temp->next; free(temp); temp = next; } cout insert(new int(10)); list->insert(new int(20)); list->insert(new int(30)); list->insert(new int(40)); list->insert(new int(50)); list->display(); list->Remove(new int(30)); list->display(); list->count(); list->search(new int(40)); cout push(new string("A")); stack->push(new string("B")); stack->pop(); stack->push(new string("C")); stack->push(new string("D")); stack->push(new string("E")); cout enqueue(new string("QA")); queue->enqueue(new string("QB")); queue->dequeue(); queue->enqueue(new string("QC")); queue->enqueue(new string("QD")); queue->enqueue(new string("QE")); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started