SlideShare a Scribd company logo
Please help solve this in C++. So the program is working fine but when submitting it, it gives me a
code -11, and I believe the problem is that after inserting the numbers it removes them one by one
until the last in the list, and when it tries to remove the last number in the list that is when it
counters the problem. Below is the full code but you just need to change something in the
SortedNumberList.h file under the bool remove function.
4.18 LAB: Sorted number list implementation with linked lists Step 1: Inspect the Node.h file
Inspect the class declaration for a doubly-linked list node in Node.h. Access Node.h by clicking on
the orange arrow next to main.cpp at the top of the coding window. The Node class has three
member variables: - a double data value, - a pointer to the next node, and - a pointer to the
previous node. Each member variable is protected. So code outside of the class must use the
provided getter and setter member functions to get or set a member variable. Node.h is read only,
since no changes are required. Step 2: Implement the Insert() member function A class for a
sorted, doubly-linked list is declared in SortedNumberList.h. Implement the SortedNumberList
class's Insert() member function. The function must create a new node with the parameter value,
then insert the node into the proper sorted position in the linked list. Ex: Suppose a
SortedNumberList's current list is 2347.2586, then Insert(33.5) is called. A new node with data
value 33.5 is created and inserted between 23 and 47.25, thus preserving the list's sorted order
and yielding: 2335.547.2586Step 3: Test in develop mode Code in main() takes a space-
separated list of numbers and inserts each into a SortedNumberList. The list is displayed after
each insertion. Ex: If input is 77154263.5 then output is: List after inserting 77 : 77 List after
inserting 15 : 1577 List after inserting -42 : -421577 List after inserting 63.5: -421563.577 Try
various program inputs, ensuring that each outputs a sorted list. Step 4: Implement the Remove()
member function Implement the SortedNumberList class's Remove(0 member function. The
function takes a parameter for the number to be removed from the list. If the number does not
exist in the list, the list is not changed and false is returned. Otherwise, the first instance of the
number is removed from the list and true is returned. Uncomment the commented-out part in
main() that reads a second input line and removes numbers from the list. Test in develop mode to
ensure that insertion and removal both work properly, then submit code for grading. Ex: If input is
841972841961 then output is: List after inserting 84: 84 List after inserting 72 : 7284 List after
inserting 19: 1972 84 List after inserting 61: 1961 : 72 8 List after removing 19: 6172 84 List after
removing 84: 6172Current file: main.cpp - // Insert each value and show the sorted List's contents
after each insertion sortedNumberList list; for (auto term : terms) { double number = stod ( term );
cout "List after inserting " number " " " endl; 1ist. Insert(number); PrintList(1ist); } // Read the input
line with numbers to remove getline (cin, inputLine); terms = spacesplit(inputLine); // Remove each
value for (auto term : terms) { double number = stod ( term ); cout "List after removing " number " "
" endl; 1ist. Remove(number); PrintList(1ist); } return ; } // Prints the sortedNumberList's contents,
in order from head to tail void PrintList(SortednumberList& list) { Node* node = 1ist. head; while
(node) { cout node->GetData( )"; node = node > GetNext () ; } cout end1; 3 // Splits a string at
each space character, adding each substring to the vector vector spacesplit(string source) { vector
=; for (size_t 1=0;1< source.length ();1++){ if (" " " source [1]){ result.push_back
(source.substr(start, 1 - start)); start =1+1 } } result. push_back(source .substr(start)); return result;
}Current file: SortedNumberList.h// Removes the node with the specified number value from the
List. Returns // true if the node is found and removed, false otherwise. bool Remove(double
number) { // Return false if the list is empty if (head == nullptr) return false; // Else if the data to be
removed is at the head node else if (head->GetData ()== number) { // Reassign the node after the
head node as the head node head = head->GetNext ( ); // Unlink the previous head node from the
list head->setprevious(nullptr); return true; } // Else the node to be removed is somewhere after the
head node else { // Create a temporary node pointing to the head node Node *temp = head; //
Traverse the List till we find a matching data while (temp != nullptr && temp->getData() I= number)
temp = temp->GetNext (); // Return false if the number is not found in the list if (temp == nullptr)
return false; // If the node to be removed is the tail node else if (temp == tail) { // set the node
previous to the tail node as the tail node tail = tail->getPrevious (); // Unlink the previous tail node
from the list tail->setNext(nullptr); return true; } // else the node to be removed is somewhere in the
middle of the list else { // remove the temp node from the list temp->Getprevious () -
>SetNext(temp->GetNext()); temp->GetNext() ->SetPrevious (temp->Getprevious ()); free(temp);
return true; 3 } 3 Run your program as often as you'd like, before submitting for grading. Below,
type any needed input values in the first box, then click Run program and observe the program's
output in the second box.More insertion and removal (negative numbers, removal until list is
empty, and so on) Returned unexpected error code (11) PASS: Removing 100 yields an empty
list. PASS: Inserting 100 yields (100) PASS: Inserting 200 yields (100,200) PASS: Inserting -77.5
yields (77.5,100,200) PASS: Inserting 22.25 yields (77.5,22.25,100,200) PASS: Inserting -150
yields (150,77.5,22.25,100,200) PASS: Inserting 500 yields (150,77.5,22.25,100,200,500) PASS:
Removing -150 yields (77.5,22.25,100,200,500) PASS: Removing 500 yields (77.5,22.25,100,200)
PASS: Removing -77.5 yields (22.25,100,200) PASS: Removing 200 yields (22.25,100) PASS:
Removing 22.25 yields (100)

More Related Content

Similar to Please help solve this in C++ So the program is working fin.pdf

C Exam Help
C Exam Help C Exam Help
C Exam Help
Programming Exam Help
 
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdfC++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
callawaycorb73779
 
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfAssignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
formicreation
 
C++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdfC++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdf
aashisha5
 
Ch17
Ch17Ch17
Ch17
Abbott
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docx
BrianGHiNewmanv
 
Please the following is the currency class of perious one- class Curre.pdf
Please the following is the currency class of perious one- class Curre.pdfPlease the following is the currency class of perious one- class Curre.pdf
Please the following is the currency class of perious one- class Curre.pdf
admin463580
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
Programming Homework Help
 
C++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdfC++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdf
saradashata
 
hello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docxhello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docx
Isaac9LjWelchq
 
Background Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdfBackground Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdf
aaseletronics2013
 
Merge radix-sort-algorithm
Merge radix-sort-algorithmMerge radix-sort-algorithm
Merge radix-sort-algorithm
Rendell Inocencio
 
Merge radix-sort-algorithm
Merge radix-sort-algorithmMerge radix-sort-algorithm
Merge radix-sort-algorithm
Rendell Inocencio
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
feelinggift
 
In the class we extensively discussed a node class called IntNode in.pdf
In the class we extensively discussed a node class called IntNode in.pdfIn the class we extensively discussed a node class called IntNode in.pdf
In the class we extensively discussed a node class called IntNode in.pdf
arjunstores123
 
Please solve the following problem using C++- Thank you Instructions-.docx
Please solve the following problem using C++- Thank you Instructions-.docxPlease solve the following problem using C++- Thank you Instructions-.docx
Please solve the following problem using C++- Thank you Instructions-.docx
PeterlqELawrenceb
 
Array linked list.ppt
Array  linked list.pptArray  linked list.ppt
Array linked list.ppt
Waf1231
 
In C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdfIn C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdf
flashfashioncasualwe
 
2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf
arshin9
 
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdfAssignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
fortmdu
 

Similar to Please help solve this in C++ So the program is working fin.pdf (20)

C Exam Help
C Exam Help C Exam Help
C Exam Help
 
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdfC++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
 
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfAssignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
 
C++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdfC++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdf
 
Ch17
Ch17Ch17
Ch17
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docx
 
Please the following is the currency class of perious one- class Curre.pdf
Please the following is the currency class of perious one- class Curre.pdfPlease the following is the currency class of perious one- class Curre.pdf
Please the following is the currency class of perious one- class Curre.pdf
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
 
C++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdfC++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdf
 
hello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docxhello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docx
 
Background Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdfBackground Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdf
 
Merge radix-sort-algorithm
Merge radix-sort-algorithmMerge radix-sort-algorithm
Merge radix-sort-algorithm
 
Merge radix-sort-algorithm
Merge radix-sort-algorithmMerge radix-sort-algorithm
Merge radix-sort-algorithm
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
 
In the class we extensively discussed a node class called IntNode in.pdf
In the class we extensively discussed a node class called IntNode in.pdfIn the class we extensively discussed a node class called IntNode in.pdf
In the class we extensively discussed a node class called IntNode in.pdf
 
Please solve the following problem using C++- Thank you Instructions-.docx
Please solve the following problem using C++- Thank you Instructions-.docxPlease solve the following problem using C++- Thank you Instructions-.docx
Please solve the following problem using C++- Thank you Instructions-.docx
 
Array linked list.ppt
Array  linked list.pptArray  linked list.ppt
Array linked list.ppt
 
In C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdfIn C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdf
 
2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf
 
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdfAssignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
 

More from ankit11134

Please modify the following code in C Here is the initial c.pdf
Please modify the following code in C Here is the initial c.pdfPlease modify the following code in C Here is the initial c.pdf
Please modify the following code in C Here is the initial c.pdf
ankit11134
 
please read below it will tell you what we are using L.pdf
please read below it will tell you what we are using   L.pdfplease read below it will tell you what we are using   L.pdf
please read below it will tell you what we are using L.pdf
ankit11134
 
Please read below instruction and please give me answer 1.pdf
Please read below instruction and please give me answer   1.pdfPlease read below instruction and please give me answer   1.pdf
Please read below instruction and please give me answer 1.pdf
ankit11134
 
Please read Sections 13 of the following paper Yufei Tao.pdf
Please read Sections 13 of the following paper  Yufei Tao.pdfPlease read Sections 13 of the following paper  Yufei Tao.pdf
Please read Sections 13 of the following paper Yufei Tao.pdf
ankit11134
 
Please provide all necessary steps b Let 2XEX+VarX.pdf
Please provide all necessary steps b Let 2XEX+VarX.pdfPlease provide all necessary steps b Let 2XEX+VarX.pdf
Please provide all necessary steps b Let 2XEX+VarX.pdf
ankit11134
 
Please provide a 150200 word response per question and incl.pdf
Please provide a 150200 word response per question and incl.pdfPlease provide a 150200 word response per question and incl.pdf
Please provide a 150200 word response per question and incl.pdf
ankit11134
 
Please only write java classes according to diagram below I.pdf
Please only write java classes according to diagram below I.pdfPlease only write java classes according to diagram below I.pdf
Please only write java classes according to diagram below I.pdf
ankit11134
 
Please mention Chicago style REFERENCES How Tourism Works A.pdf
Please mention Chicago style REFERENCES How Tourism Works A.pdfPlease mention Chicago style REFERENCES How Tourism Works A.pdf
Please mention Chicago style REFERENCES How Tourism Works A.pdf
ankit11134
 
Please present complete solution The data in the table below.pdf
Please present complete solution The data in the table below.pdfPlease present complete solution The data in the table below.pdf
Please present complete solution The data in the table below.pdf
ankit11134
 
Please pick a relevant company or make one up Consider the .pdf
Please pick a relevant company or make one up Consider the .pdfPlease pick a relevant company or make one up Consider the .pdf
Please pick a relevant company or make one up Consider the .pdf
ankit11134
 
Please help with the concept map for eukaryotic transcriptio.pdf
Please help with the concept map for eukaryotic transcriptio.pdfPlease help with the concept map for eukaryotic transcriptio.pdf
Please help with the concept map for eukaryotic transcriptio.pdf
ankit11134
 
Please modify the following code in C Make sure your code m.pdf
Please modify the following code in C Make sure your code m.pdfPlease modify the following code in C Make sure your code m.pdf
Please modify the following code in C Make sure your code m.pdf
ankit11134
 
Please match using only the given options Match the definiti.pdf
Please match using only the given options Match the definiti.pdfPlease match using only the given options Match the definiti.pdf
Please match using only the given options Match the definiti.pdf
ankit11134
 
Please match each component of the logic model presented her.pdf
Please match each component of the logic model presented her.pdfPlease match each component of the logic model presented her.pdf
Please match each component of the logic model presented her.pdf
ankit11134
 
please make feedbackcomment or response to this post Pro.pdf
please make feedbackcomment or response to this post   Pro.pdfplease make feedbackcomment or response to this post   Pro.pdf
please make feedbackcomment or response to this post Pro.pdf
ankit11134
 
please make feedbackcomment or response to this post Being.pdf
please make feedbackcomment or response to this post Being.pdfplease make feedbackcomment or response to this post Being.pdf
please make feedbackcomment or response to this post Being.pdf
ankit11134
 
Please make a lab report with the following Linux command li.pdf
Please make a lab report with the following Linux command li.pdfPlease make a lab report with the following Linux command li.pdf
Please make a lab report with the following Linux command li.pdf
ankit11134
 
Please label the image given characteristics Basement me.pdf
Please label the image given characteristics   Basement me.pdfPlease label the image given characteristics   Basement me.pdf
Please label the image given characteristics Basement me.pdf
ankit11134
 
Please include formulas This problem is based on a real acqu.pdf
Please include formulas This problem is based on a real acqu.pdfPlease include formulas This problem is based on a real acqu.pdf
Please include formulas This problem is based on a real acqu.pdf
ankit11134
 
Please help Two firms engage in simultaneousmove quantity .pdf
Please help Two firms engage in simultaneousmove quantity .pdfPlease help Two firms engage in simultaneousmove quantity .pdf
Please help Two firms engage in simultaneousmove quantity .pdf
ankit11134
 

More from ankit11134 (20)

Please modify the following code in C Here is the initial c.pdf
Please modify the following code in C Here is the initial c.pdfPlease modify the following code in C Here is the initial c.pdf
Please modify the following code in C Here is the initial c.pdf
 
please read below it will tell you what we are using L.pdf
please read below it will tell you what we are using   L.pdfplease read below it will tell you what we are using   L.pdf
please read below it will tell you what we are using L.pdf
 
Please read below instruction and please give me answer 1.pdf
Please read below instruction and please give me answer   1.pdfPlease read below instruction and please give me answer   1.pdf
Please read below instruction and please give me answer 1.pdf
 
Please read Sections 13 of the following paper Yufei Tao.pdf
Please read Sections 13 of the following paper  Yufei Tao.pdfPlease read Sections 13 of the following paper  Yufei Tao.pdf
Please read Sections 13 of the following paper Yufei Tao.pdf
 
Please provide all necessary steps b Let 2XEX+VarX.pdf
Please provide all necessary steps b Let 2XEX+VarX.pdfPlease provide all necessary steps b Let 2XEX+VarX.pdf
Please provide all necessary steps b Let 2XEX+VarX.pdf
 
Please provide a 150200 word response per question and incl.pdf
Please provide a 150200 word response per question and incl.pdfPlease provide a 150200 word response per question and incl.pdf
Please provide a 150200 word response per question and incl.pdf
 
Please only write java classes according to diagram below I.pdf
Please only write java classes according to diagram below I.pdfPlease only write java classes according to diagram below I.pdf
Please only write java classes according to diagram below I.pdf
 
Please mention Chicago style REFERENCES How Tourism Works A.pdf
Please mention Chicago style REFERENCES How Tourism Works A.pdfPlease mention Chicago style REFERENCES How Tourism Works A.pdf
Please mention Chicago style REFERENCES How Tourism Works A.pdf
 
Please present complete solution The data in the table below.pdf
Please present complete solution The data in the table below.pdfPlease present complete solution The data in the table below.pdf
Please present complete solution The data in the table below.pdf
 
Please pick a relevant company or make one up Consider the .pdf
Please pick a relevant company or make one up Consider the .pdfPlease pick a relevant company or make one up Consider the .pdf
Please pick a relevant company or make one up Consider the .pdf
 
Please help with the concept map for eukaryotic transcriptio.pdf
Please help with the concept map for eukaryotic transcriptio.pdfPlease help with the concept map for eukaryotic transcriptio.pdf
Please help with the concept map for eukaryotic transcriptio.pdf
 
Please modify the following code in C Make sure your code m.pdf
Please modify the following code in C Make sure your code m.pdfPlease modify the following code in C Make sure your code m.pdf
Please modify the following code in C Make sure your code m.pdf
 
Please match using only the given options Match the definiti.pdf
Please match using only the given options Match the definiti.pdfPlease match using only the given options Match the definiti.pdf
Please match using only the given options Match the definiti.pdf
 
Please match each component of the logic model presented her.pdf
Please match each component of the logic model presented her.pdfPlease match each component of the logic model presented her.pdf
Please match each component of the logic model presented her.pdf
 
please make feedbackcomment or response to this post Pro.pdf
please make feedbackcomment or response to this post   Pro.pdfplease make feedbackcomment or response to this post   Pro.pdf
please make feedbackcomment or response to this post Pro.pdf
 
please make feedbackcomment or response to this post Being.pdf
please make feedbackcomment or response to this post Being.pdfplease make feedbackcomment or response to this post Being.pdf
please make feedbackcomment or response to this post Being.pdf
 
Please make a lab report with the following Linux command li.pdf
Please make a lab report with the following Linux command li.pdfPlease make a lab report with the following Linux command li.pdf
Please make a lab report with the following Linux command li.pdf
 
Please label the image given characteristics Basement me.pdf
Please label the image given characteristics   Basement me.pdfPlease label the image given characteristics   Basement me.pdf
Please label the image given characteristics Basement me.pdf
 
Please include formulas This problem is based on a real acqu.pdf
Please include formulas This problem is based on a real acqu.pdfPlease include formulas This problem is based on a real acqu.pdf
Please include formulas This problem is based on a real acqu.pdf
 
Please help Two firms engage in simultaneousmove quantity .pdf
Please help Two firms engage in simultaneousmove quantity .pdfPlease help Two firms engage in simultaneousmove quantity .pdf
Please help Two firms engage in simultaneousmove quantity .pdf
 

Recently uploaded

The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 

Recently uploaded (20)

The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 

Please help solve this in C++ So the program is working fin.pdf

  • 1. Please help solve this in C++. So the program is working fine but when submitting it, it gives me a code -11, and I believe the problem is that after inserting the numbers it removes them one by one until the last in the list, and when it tries to remove the last number in the list that is when it counters the problem. Below is the full code but you just need to change something in the SortedNumberList.h file under the bool remove function. 4.18 LAB: Sorted number list implementation with linked lists Step 1: Inspect the Node.h file Inspect the class declaration for a doubly-linked list node in Node.h. Access Node.h by clicking on the orange arrow next to main.cpp at the top of the coding window. The Node class has three member variables: - a double data value, - a pointer to the next node, and - a pointer to the previous node. Each member variable is protected. So code outside of the class must use the provided getter and setter member functions to get or set a member variable. Node.h is read only, since no changes are required. Step 2: Implement the Insert() member function A class for a sorted, doubly-linked list is declared in SortedNumberList.h. Implement the SortedNumberList class's Insert() member function. The function must create a new node with the parameter value, then insert the node into the proper sorted position in the linked list. Ex: Suppose a SortedNumberList's current list is 2347.2586, then Insert(33.5) is called. A new node with data value 33.5 is created and inserted between 23 and 47.25, thus preserving the list's sorted order and yielding: 2335.547.2586Step 3: Test in develop mode Code in main() takes a space- separated list of numbers and inserts each into a SortedNumberList. The list is displayed after each insertion. Ex: If input is 77154263.5 then output is: List after inserting 77 : 77 List after inserting 15 : 1577 List after inserting -42 : -421577 List after inserting 63.5: -421563.577 Try various program inputs, ensuring that each outputs a sorted list. Step 4: Implement the Remove() member function Implement the SortedNumberList class's Remove(0 member function. The function takes a parameter for the number to be removed from the list. If the number does not exist in the list, the list is not changed and false is returned. Otherwise, the first instance of the number is removed from the list and true is returned. Uncomment the commented-out part in main() that reads a second input line and removes numbers from the list. Test in develop mode to ensure that insertion and removal both work properly, then submit code for grading. Ex: If input is 841972841961 then output is: List after inserting 84: 84 List after inserting 72 : 7284 List after inserting 19: 1972 84 List after inserting 61: 1961 : 72 8 List after removing 19: 6172 84 List after removing 84: 6172Current file: main.cpp - // Insert each value and show the sorted List's contents after each insertion sortedNumberList list; for (auto term : terms) { double number = stod ( term ); cout "List after inserting " number " " " endl; 1ist. Insert(number); PrintList(1ist); } // Read the input line with numbers to remove getline (cin, inputLine); terms = spacesplit(inputLine); // Remove each value for (auto term : terms) { double number = stod ( term ); cout "List after removing " number " " " endl; 1ist. Remove(number); PrintList(1ist); } return ; } // Prints the sortedNumberList's contents, in order from head to tail void PrintList(SortednumberList& list) { Node* node = 1ist. head; while (node) { cout node->GetData( )"; node = node > GetNext () ; } cout end1; 3 // Splits a string at each space character, adding each substring to the vector vector spacesplit(string source) { vector =; for (size_t 1=0;1< source.length ();1++){ if (" " " source [1]){ result.push_back (source.substr(start, 1 - start)); start =1+1 } } result. push_back(source .substr(start)); return result; }Current file: SortedNumberList.h// Removes the node with the specified number value from the
  • 2. List. Returns // true if the node is found and removed, false otherwise. bool Remove(double number) { // Return false if the list is empty if (head == nullptr) return false; // Else if the data to be removed is at the head node else if (head->GetData ()== number) { // Reassign the node after the head node as the head node head = head->GetNext ( ); // Unlink the previous head node from the list head->setprevious(nullptr); return true; } // Else the node to be removed is somewhere after the head node else { // Create a temporary node pointing to the head node Node *temp = head; // Traverse the List till we find a matching data while (temp != nullptr && temp->getData() I= number) temp = temp->GetNext (); // Return false if the number is not found in the list if (temp == nullptr) return false; // If the node to be removed is the tail node else if (temp == tail) { // set the node previous to the tail node as the tail node tail = tail->getPrevious (); // Unlink the previous tail node from the list tail->setNext(nullptr); return true; } // else the node to be removed is somewhere in the middle of the list else { // remove the temp node from the list temp->Getprevious () - >SetNext(temp->GetNext()); temp->GetNext() ->SetPrevious (temp->Getprevious ()); free(temp); return true; 3 } 3 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box.More insertion and removal (negative numbers, removal until list is empty, and so on) Returned unexpected error code (11) PASS: Removing 100 yields an empty list. PASS: Inserting 100 yields (100) PASS: Inserting 200 yields (100,200) PASS: Inserting -77.5 yields (77.5,100,200) PASS: Inserting 22.25 yields (77.5,22.25,100,200) PASS: Inserting -150 yields (150,77.5,22.25,100,200) PASS: Inserting 500 yields (150,77.5,22.25,100,200,500) PASS: Removing -150 yields (77.5,22.25,100,200,500) PASS: Removing 500 yields (77.5,22.25,100,200) PASS: Removing -77.5 yields (22.25,100,200) PASS: Removing 200 yields (22.25,100) PASS: Removing 22.25 yields (100)