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

Please modify our existing ClassDemo2 (please find it on Canvas site) program an

ID: 3722303 • Letter: P

Question

Please modify our existing ClassDemo2 (please find it on Canvas site) program and add characters (char) and names (strings) to be added to the linked list along with integers. The current demo program accepts only integer data, so you would ask the user to select the data type to be added to the linked list. The user should be given the following three choices:

(a) whole numbers

(b) single characters

(c) strings

Once the user makes a selection from the list above then your program should be able to process the data appropriately. This includes:

(a) insert

(b) print

(c) delete

(d) search

(e) copy

You will use the existing code (class demo file) and modify it to process char and string data type.

Please upload .cpp file(s) along with screenshots of all solutions/screens. You can take a screenshot of your solutions by hitting PrintScreen button on your keyboard and then by pasting that image into a Word document.

Explanation / Answer

the code has modified

#include <iostream>

using namespace std;

struct nodeType
{
int info;
nodeType *link;
};

int main()
{
nodeType *head = new nodeType;

head->link = new nodeType;
head->info = 17;
cout << head->info << " " << head->link << endl;
system("pause");   
head->link->link = new nodeType;
head->link->info = 23;
cout << head->link->info << " " << head->link->link << endl;

head->link->link->link = new nodeType;
head->link->link->info = 50;
cout << head->link->link->info << " " << head->link->link->link << endl;

head->link->link->link->link = NULL;
//the last link
cout << "Last: "<< head->link->link->link->link << endl;


//Insert
//nodeType *s, *t, *insertNode = new nodeType;
//insertNode->info = 100;
//s = head;
//t = head->link;
//cout << "s and t : " << s << " " << t << endl;

//s->link = insertNode;
//insertNode->link = t;
//cout << "s and t : " << " " << s->link << " " << t->link << endl;
//
//delete
//s = s->link;
//cout << "New Numbers Info: " << s->info << " " << s->link->info << " " << s->link->link->info << endl;


nodeType *current;
current = head;
  
cout << "current: " << current->info << " " << current->link << endl;//17

current = current->link;//go to the next node
cout << "current: " << current->info << " " << current->link << endl;//23

current = current->link;//go to the following node
cout << "current: " << current->info << " " << current->link << endl;//50
cout << "current Last: "<< current->link->link << endl;

nodeType *p;
p = head;
for(int i=0; i<4; i++)
{
cout << "p: " << p->info << " " << p->link << endl;
p = p->link;//go to the next node
}
  
cout << "p Last: "<< p->link << endl;

cout << "NewNode" << endl;
nodeType *newNode;
newNode = head;
cout << head->link << endl;
cout << newNode->link << endl;

while (newNode != NULL)
{
cout << "newNode: " << newNode->info << " " << newNode->link << endl;
/* if(newNode->link == NULL)
cout << "Null" << endl; */   
newNode = newNode->link;
}

return 0;
}

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