C++ language. Using the coding prepared below, add and create the Undo last pop, Display undo list and Redo Functions void functions but keep them as they are. NOTE: use the coding given, i don't want...


C++ language. Using the coding prepared below, add and create the
Undo last pop, Display undo list andRedo Functionsvoid functions but keep them as they are.


NOTE: use the coding given, i don't want a new coding


The code:


#include
#include
#include


using namespace std;


struct nodeWords
{
    char words[100];

    struct nodeWords *next;
};


nodeWords* top; //these pointers are used to hold the linked list.
nodeWords* current; //use for traversal
nodeWords* newNode; //use to create new node for new record
nodeWords* pop;


void Push()
{
    char answer;
    do
    {
        newNode = new nodeWords;


        cout < "\nwrite="" what's="" in="" your="" mind.."=""><>
        cout < "your="" words=""> ";
        cin >> ws;
        cin.getline(newNode->words, 100);

        newNode->next = top;
        top = newNode;

        cout < "\nwant="" to="" write="" more?="" press="" y="" for="" yes="" and="" n="" for="" no:="">
        cin >> answer;
    } while (toupper(answer) == 'Y');
}


void stacktop()
{
    if (top == NULL)
    {
        cout < "\nthere="" is="" no="">
    }
    else
    {
        cout < "\nthe="" top="" element="" is.....="">
        cout < "\nyour="" words=""> " < top-="">words <>
    }
}


void display()
{
    char answer2;
    int no = 1;
    int totalRecord = 0;
    int view;
    {


        cout < endl="">< left="">< setw(5)="">< "no"="">< setw(50)="">< "your="" words"=""><>
        cout < "----------------------------------------------------------------------"=""><>
        current = top;
        while (current != NULL)
        {
            cout < left="">< setw(5)="">< no="">< setw(50)="">< current-="">words <>
            no++;
            current = current->next;
            totalRecord++;
        }
        cout < "----------------------------------------------------------------------"=""><>
        cout < "\ntotal="" number="" of="" records:="" "="">< totalrecord=""><>


    }
    cout < "\npress="" y="" to="" go="" back="" to="" main="" menu:="">
    cin >> answer2;
    }

void Pop()
{
        current = top;


        while (current != NULL)
        {

            pop = current;


            if (current == top)
            {
                top = top->next;
                current = NULL;
                delete pop;
                cout < "\n\npop="" operation="">
            }
            else{
                    top = NULL;
                    current = NULL;
                    current = NULL;
                    delete pop;
                    cout < "\n\npop="" operation="">
            }
        }
}




int main()
{
    int menuOption;


    top = NULL; //create list
    do
    {
        cout <>
        cout < "\t\tmain="">
        cout <>
        cout < "1="" -="" push/add="" record="">
        cout < "2="" -="" peek/stack="" top="">
        cout < "3="" -="" pop/remove="" record="">
        cout < "4="" -="">
        cout < "5="" -="">
        cout < "6="" -="">
        cout < "7="" -="">
        cout <>


        cout < "enter="" your="" option="" [1,="" 2,="" 3,="" 4,="" 5,="" 6,="" 7]:="">
        cin >> menuOption;


        switch (menuOption)
        {
        case 1: Push();
            break;


        case 2: stacktop();
            break;


        case 3: current = top;
            if (current == NULL)
            {
                cout < "\n\n="" the="" list="" is="">
                cout < "unable="" to="" perform="" the="" delete="">
            }
            else {
                Pop();
            }
            break;


        case 4: display();
            break;

     /* case 5: undo();
            break;

        case 6: redo();
            break; */

        case 7: cout < system("cls")="">< "\n\n\t="" program="">
            break;


        default: cout < "wrong="" option.="" please="" re-enter="" your="">
        }
    } while (menuOption != 5);


    return 0;
}

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here