Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLEASE DO NOT COMPLICATE THE PROGRAM. I NEED IT URGENTLY ASAP. USE C++ AND DO NO

ID: 3860506 • Letter: P

Question

PLEASE DO NOT COMPLICATE THE PROGRAM. I NEED IT URGENTLY ASAP. USE C++ AND DO NOT WRITE IT FROM ONLINE. DO NOT USE POINTERS. ONLY USE LINKED LIST.

Modify the Program such that the program gives a menu option to (1) add a node with a value, (2) delete a node with a value, (3) terminate the program. (You need to have the complete header file, NumberList.h, which include the NumberList class with its member functions defined.)

Whenever a node is added or deleted the contents of the linked list should be displayed on the screen.

The program is listed below:

// This program demonstrates the deleteNode member function.


#include <iostream>
#include "NumberList.h"

using namespace std;

int main()
{

// Define a NumberList object.

NumberList list;

// Build the list with some values.

list.appendNode(2.5);
list.appendNode(7.9);
list.appendNode(12.6);

// Display the list.

cout << "Here are the initial values: ";
list.displayList();
cout << endl;

// Delete the middle node.

cout << "Now deleting the node in the middle: ";
list.deleteNode(7.9);

// Display the list.

cout << "Here are the nodes left. ";
list.displayList();
cout << endl;

// Delete the last node.

cout << "Now deleting the last node: ";
list.deleteNode(12.6);

// Display the list.

cout << "Here are the nodes left. ";
list.displayList();
cout << endl;

// Delete the only node left in the list.

cout << "Now deleting the only remaining node. ";
list.deleteNode(2.5);

// Display the list.

cout << "Here are the nodes left. ";
list.displayList();

return 0;

}

Explanation / Answer

int main()

{

int choice = 1;

while (choice !=3)

{

cout << "1. Add a node. ";

cout << "2. Delete a node with given value. ";

cout << "3. Terminate the program. ";

cout << "Enter your choice : ";

cin >> choice;

if (choice == 1)

{

float val;

cout << "Enter value to be inserted: ";

cin >> val;

list.appendNode(val);

cout << "Here is the current list: ";

list.displayList();

}

else if (choice == 2)

{

float val;

cout << "Enter value to be deleted : ";

cin >> val;

list.deleteNode(val);

cout << "Here are the nodes left : ";

list.displayList();

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote