Can you finish the code pleaseaccording to the instruction For the stack, perform the following operations in order -  Push seven (7) objects starting from the array index 13 onwards to the stack. Peek the top of the stack - print the result. Perform three (3) pops in succession. Print the contents of the stack. Push five (5) more objects from the start of the objects array to the stack. Pop twice in succession. Print the contents of the stack. For the queue, perform the following operations in order -  Enqueue the seven (7) objects at odd indexes starting from index 5 in the array. Peek the front and end of the queue - print the results. Perform two (2) dequeues in succession. Print the contents of the queue. Enqueue five (5) more objects from the index 10 in the array. Dequeue three times in succession. 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 "Currency.h" #include "SinglyLinkedList.h" #include "Stack.h" #include "Queue.h" using namespace std; int main() {     // Welcome message     cout << "Welcome to the demonstration of ADTs by [your full name]" << endl << endl;     // Create the Currency array     Currency currencies[20] = {         Currency(57.12),         Currency(23.44),         Currency(87.43),         Currency(68.99),         Currency(111.22),         Currency(44.55),         Currency(77.77),         Currency(18.36),         Currency(543.21),         Currency(20.21),         Currency(345.67),         Currency(36.18),         Currency(48.48),         Currency(101.00),         Currency(11.00),         Currency(21.00),         Currency(51.00),         Currency(1.00),         Currency(251.00),         Currency(151.00)     };     // Create SinglyLinkedList object     SinglyLinkedList currencyList;     // Add first 7 objects to the linked list in reverse order     for (int i = 6; i >= 0; i--) {         currencyList.addFirst(currencies[i]);     }     // Search for Kr 87.43 followed by Kr 44.56 - print the results of each     cout << "Search for Kr 87.43: " << (currencyList.search(Currency(87.43)) ? "Found" : "Not found") << endl;     cout << "Search for Kr 44.56: " << (currencyList.search(Currency(44.56)) ? "Found" : "Not found") << endl;     // Remove node containing Kr 111.22 followed by the node at index 2     currencyList.remove(Currency(111.22));     currencyList.removeAt(2);     // Print contents of the list     cout << "Contents of the list: ";     currencyList.print();     // Add next 4 objects to the list     for (int i = 8; i < 12; i++) {         currencyList.add((i % 5), currencies[i]);     }     // Remove two objects at indexes (countCurrency % 6) and (countCurrency / 7)     int countCurrency = currencyList.size();     currencyList.removeAt(countCurrency % 6);     currencyList.removeAt(countCurrency / 7);     // Print contents of the list     cout << "Contents of the list: ";     currencyList.print();     // Create Stack object     Stack currencyStack;     // Push seven objects starting from array index 13 to the stack     for (int i = 13; i < 20; i++) {         currencyStack.push(currencies[i]);     }     // Peek the top of the stack     cout << "Top of the stack: " << currencyStack.peek() << endl;     // Perform three pops in succession     cout << "Popping three elements: ";     for (int i = 0; i < 3; i++) {         cout << currencyStack.pop() << " ";     }     cout << endl;     // Print contents of the stack     cout << "Contents of the stack: ";     currencyStack.print();     // Push five objects from the start of the objects array to the stack     for (int i = 0; i < 5; i++)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Topic Video
Question

Can you finish the code pleaseaccording to the instruction

    • For the stack, perform the following operations in order - 
        1. Push seven (7) objects starting from the array index 13 onwards to the stack.
        2. Peek the top of the stack - print the result.
        3. Perform three (3) pops in succession.
        4. Print the contents of the stack.
        5. Push five (5) more objects from the start of the objects array to the stack.
        6. Pop twice in succession.
        7. Print the contents of the stack.
    • For the queue, perform the following operations in order - 
        1. Enqueue the seven (7) objects at odd indexes starting from index 5 in the array.
        2. Peek the front and end of the queue - print the results.
        3. Perform two (2) dequeues in succession.
        4. Print the contents of the queue.
        5. Enqueue five (5) more objects from the index 10 in the array.
        6. Dequeue three times in succession.
        7. 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 <iostream>
#include "Currency.h"
#include "SinglyLinkedList.h"
#include "Stack.h"
#include "Queue.h"

using namespace std;

int main() {
    // Welcome message
    cout << "Welcome to the demonstration of ADTs by [your full name]" << endl << endl;

    // Create the Currency array
    Currency currencies[20] = {
        Currency(57.12),
        Currency(23.44),
        Currency(87.43),
        Currency(68.99),
        Currency(111.22),
        Currency(44.55),
        Currency(77.77),
        Currency(18.36),
        Currency(543.21),
        Currency(20.21),
        Currency(345.67),
        Currency(36.18),
        Currency(48.48),
        Currency(101.00),
        Currency(11.00),
        Currency(21.00),
        Currency(51.00),
        Currency(1.00),
        Currency(251.00),
        Currency(151.00)
    };

    // Create SinglyLinkedList object
    SinglyLinkedList<Currency> currencyList;

    // Add first 7 objects to the linked list in reverse order
    for (int i = 6; i >= 0; i--) {
        currencyList.addFirst(currencies[i]);
    }

    // Search for Kr 87.43 followed by Kr 44.56 - print the results of each
    cout << "Search for Kr 87.43: " << (currencyList.search(Currency(87.43)) ? "Found" : "Not found") << endl;
    cout << "Search for Kr 44.56: " << (currencyList.search(Currency(44.56)) ? "Found" : "Not found") << endl;

    // Remove node containing Kr 111.22 followed by the node at index 2
    currencyList.remove(Currency(111.22));
    currencyList.removeAt(2);

    // Print contents of the list
    cout << "Contents of the list: ";
    currencyList.print();

    // Add next 4 objects to the list
    for (int i = 8; i < 12; i++) {
        currencyList.add((i % 5), currencies[i]);
    }

    // Remove two objects at indexes (countCurrency % 6) and (countCurrency / 7)
    int countCurrency = currencyList.size();
    currencyList.removeAt(countCurrency % 6);
    currencyList.removeAt(countCurrency / 7);

    // Print contents of the list
    cout << "Contents of the list: ";
    currencyList.print();

    // Create Stack object
    Stack<Currency> currencyStack;

    // Push seven objects starting from array index 13 to the stack
    for (int i = 13; i < 20; i++) {
        currencyStack.push(currencies[i]);
    }

    // Peek the top of the stack
    cout << "Top of the stack: " << currencyStack.peek() << endl;

    // Perform three pops in succession
    cout << "Popping three elements: ";
    for (int i = 0; i < 3; i++) {
        cout << currencyStack.pop() << " ";
    }
    cout << endl;

    // Print contents of the stack
    cout << "Contents of the stack: ";
    currencyStack.print();

    // Push five objects from the start of the objects array to the stack
    for (int i = 0; i < 5; i++)

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education