Question: Main.cpp #include #include #include #include SortedNumberList.h using namespace std; int main ( ) { bool includeRemovals = false; / / Numbers to insert during

Main.cpp
#include
#include
#include
#include "SortedNumberList.h"
using namespace std;
int main(){
bool includeRemovals = false;
// Numbers to insert during first loop:
vector numbersToInsert ={
77.75,15.25,-4.25,63.5,18.25,-3.5
};
// Insert each number and print sorted list's contents after each insertion
SortedNumberList list;
cout fixed setprecision(2);
for (auto number : numbersToInsert){
cout "List after inserting " number ": ";
list.Insert(number);
list.Print(cout,",","","
");
}
if (includeRemovals){
cout endl;
vector numbersToRemove ={
77.75,// List's last element
-4.25,// List's first element
18.25,// Neither first nor last element
// Remaining elements:
15.25,63.5,-3.5
};
// Remove numbers
for (auto toRemove : numbersToRemove){
cout "List after removing " toRemove ": ";
list.Remove(toRemove);
list.Print(cout,",","","
");
}
}
return 0;
}
SortedNumberList.h
#ifndef SORTEDNUMBERLIST_H
#define SORTEDNUMBERLIST_H
#include "NumberList.h"
class SortedNumberList : public NumberList {
private:
// Optional: Add any desired private functions here
public:
SortedNumberList(){
head = nullptr;
tail = nullptr;
}
// Inserts the number into the list in the correct position such that the
// list remains sorted in ascending order.
void Insert(double number){
// TODO: Type your code here
}
// 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){
// TODO: Type your code here
return false;
}
};
#endif
Main.cpp #include #include #include #include

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!