Question: this is all code of what u need to know about this is arraylistType.h // #include //Line 1 #include //Line 2 #include #include arrayListType.h //Line



this is all code of what u need to know about
this is arraylistType.h //
#include //Line 1
#include //Line 2
#include
#include "arrayListType.h" //Line
using namespace std; //Line 4
int main() //Line 5
{
arrayListType L(7),L2(7);
L.insertEnd(2);
L.insertEnd(1);
L.insertEnd(3);
L.insertEnd(4);
L.insertEnd(3);
L.insertEnd(3);
L.insertEnd(2);
cout << "List L before differentiate(L) contains:" << endl;
L.print();
cout<<"differentiate(L) = "<< differentiate(L)<
cout << "List L after differentiate(L) contains:" << endl;
L.print();
cout<
L.clearList();
L.insertEnd(2);
L.insertEnd(1);
L.insertEnd(3);
L.insertEnd(4);
L.insertEnd(3);
L.insertEnd(3);
L.insertEnd(2);
cout << "List L before averageEach2(L) contains:" << endl;
L.print();
cout<<"calling averageEach2(L)"<
averageEach2(L);
cout << "List L after averageEach2(L) contains:" << endl;
L.print();
cout<
L.clearList();
L.insertEnd(2);
L.insertEnd(1);
L.insertEnd(3);
L.insertEnd(4);
L.insertEnd(3);
L.insertEnd(3);
L.insertEnd(2);
cout << "List L before keepPalindrome(L) contains:" << endl;
L.print();
cout<<"calling keepPalindrome(L)"<
keepPalindrome(L);
cout << "List L after keepPalindrome(L) contains:" << endl;
L.print();
cout<
arrayListType cL(8);//a,c,d,f,f,g,c,z
cL.insertEnd('a');
cL.insertEnd('c');
cL.insertEnd('d');
cL.insertEnd('f');
cL.insertEnd('f');
cL.insertEnd('g');
cL.insertEnd('c');
cL.insertEnd('z');
cout << "List cL before keepPalindrome(cL) contains:" << endl;
cL.print();
cout<<"calling keepPalindrome(cL)"<
keepPalindrome(cL);
cout << "List cL after keepPalindrome(cL) contains:" << endl;
cL.print();
cout<
L2.clearList();
cout << "List L before fill(L,"reverse", L2) contains:" << endl;
L.print();
cout << "List L2 before fill(L,"reverse", L2) contains:" << endl;
L2.print();
cout<<"calling fill(L,"reverse", L2);"<
fill(L,"reverse", L2);
cout << "List L after fill(L,"reverse", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
L2.insertEnd(2);
L2.insertEnd(1);
L2.insertEnd(3);
L2.insertEnd(4);
L2.insertEnd(3);
L2.insertEnd(3);
L2.insertEnd(2);
cout << "List L before fill(L,"reverse", L2) contains:" << endl;
L.print();
cout << "List L2 before fill(L,"reverse", L2) contains:" << endl;
L2.print();
cout<<"calling fill(L,"reverse", L2);"<
fill(L,"reverse", L2);
cout << "List L after fill(L,"reverse", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
cout << "List L before fill(L,"1half", L2) contains:" << endl;
L.print();
cout << "List L2 before fill(L,"1half", L2) contains:" << endl;
L2.print();
cout<<"calling fill(L,"1half", L2);"<
fill(L,"1half", L2);
cout << "List L after fill(L,"1half", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
L2.insertEnd(2);
L2.insertEnd(1);
L2.insertEnd(3);
L2.insertEnd(4);
L2.insertEnd(3);
L2.insertEnd(3);
L2.insertEnd(2);
cout << "List L before fill(L,"1half", L2) contains:" << endl;
L.print();
cout << "List L2 before fill(L,"1half", L2) contains:" << endl;
L2.print();
cout<<"calling fill(L,"1half", L2);"<
fill(L,"1half", L2);
cout << "List L after fill(L,"1half", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
cout << "List L before fill(L,"2half", L2) contains:" << endl;
L.print();
cout << "List L2 before fill(L,"2half", L2) contains:" << endl;
L2.print();
cout<<"calling fill(L,"2half", L2);"<
fill(L,"2half", L2);
cout << "List L after fill(L,"2half", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
L2.insertEnd(2);
L2.insertEnd(1);
L2.insertEnd(3);
L2.insertEnd(4);
L2.insertEnd(3);
L2.insertEnd(3);
L2.insertEnd(2);
cout << "List L before fill(L,"2half", L2) contains:" << endl;
L.print();
cout << "List L2 before fill(L,"2half", L2) contains:" << endl;
L2.print();
cout<<"calling fill(L,"2half", L2);"<
fill(L,"2half", L2);
cout << "List L after fill(L,"2half", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
cout << "List L before fill(L,"duplicate", L2) contains:" << endl;
L.print();
cout << "List L2 before fill(L,"duplicate", L2) contains:" << endl;
L2.print();
cout<<"calling fill(L,"duplicate", L2);"<
fill(L,"duplicate", L2);
cout << "List L after fill(L,"duplicate", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
L2.insertEnd(2);
L2.insertEnd(1);
L2.insertEnd(3);
L2.insertEnd(4);
L2.insertEnd(3);
L2.insertEnd(3);
L2.insertEnd(2);
cout << "List L before fill(L,"duplicate", L2) contains:" << endl;
L.print();
cout << "List L2 before fill(L,"duplicate", L2) contains:" << endl;
L2.print();
cout<<"calling fill(L,"duplicate", L2);"<
fill(L,"duplicate", L2);
cout << "List L after fill(L,"duplicate", L2) contains:" << endl;
L.print();
cout<
return 0;
}
this member func//
#include //Line 1
#include //Line 2
#include
#include "arrayListType.h" //Line
using namespace std; //Line 4
int main() //Line 5
{
arrayListType L(7),L2(7);
L.insertEnd(2);
L.insertEnd(1);
L.insertEnd(3);
L.insertEnd(4);
L.insertEnd(3);
L.insertEnd(3);
L.insertEnd(2);
cout << "List L before differentiate(L) contains:" << endl;
L.print();
cout<<"differentiate(L) = "<< differentiate(L)<
cout << "List L after differentiate(L) contains:" << endl;
L.print();
cout<
L.clearList();
L.insertEnd(2);
L.insertEnd(1);
L.insertEnd(3);
L.insertEnd(4);
L.insertEnd(3);
L.insertEnd(3);
L.insertEnd(2);
cout << "List L before averageEach2(L) contains:" << endl;
L.print();
cout<<"calling averageEach2(L)"<
averageEach2(L);
cout << "List L after averageEach2(L) contains:" << endl;
L.print();
cout<
L.clearList();
L.insertEnd(2);
L.insertEnd(1);
L.insertEnd(3);
L.insertEnd(4);
L.insertEnd(3);
L.insertEnd(3);
L.insertEnd(2);
cout << "List L before keepPalindrome(L) contains:" << endl;
L.print();
cout<<"calling keepPalindrome(L)"<
keepPalindrome(L);
cout << "List L after keepPalindrome(L) contains:" << endl;
L.print();
cout<
arrayListType cL(8);//a,c,d,f,f,g,c,z
cL.insertEnd('a');
cL.insertEnd('c');
cL.insertEnd('d');
cL.insertEnd('f');
cL.insertEnd('f');
cL.insertEnd('g');
cL.insertEnd('c');
cL.insertEnd('z');
cout << "List cL before keepPalindrome(cL) contains:" << endl;
cL.print();
cout<<"calling keepPalindrome(cL)"<
keepPalindrome(cL);
cout << "List cL after keepPalindrome(cL) contains:" << endl;
cL.print();
cout<
L2.clearList();
cout << "List L before fill(L,"reverse", L2) contains:" << endl;
L.print();
cout << "List L2 before fill(L,"reverse", L2) contains:" << endl;
L2.print();
cout<<"calling fill(L,"reverse", L2);"<
fill(L,"reverse", L2);
cout << "List L after fill(L,"reverse", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
L2.insertEnd(2);
L2.insertEnd(1);
L2.insertEnd(3);
L2.insertEnd(4);
L2.insertEnd(3);
L2.insertEnd(3);
L2.insertEnd(2);
cout << "List L before fill(L,"reverse", L2) contains:" << endl;
L.print();
cout << "List L2 before fill(L,"reverse", L2) contains:" << endl;
L2.print();
cout<<"calling fill(L,"reverse", L2);"<
fill(L,"reverse", L2);
cout << "List L after fill(L,"reverse", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
cout << "List L before fill(L,"1half", L2) contains:" << endl;
L.print();
cout << "List L2 before fill(L,"1half", L2) contains:" << endl;
L2.print();
cout<<"calling fill(L,"1half", L2);"<
fill(L,"1half", L2);
cout << "List L after fill(L,"1half", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
L2.insertEnd(2);
L2.insertEnd(1);
L2.insertEnd(3);
L2.insertEnd(4);
L2.insertEnd(3);
L2.insertEnd(3);
L2.insertEnd(2);
cout << "List L before fill(L,"1half", L2) contains:" << endl;
L.print();
cout << "List L2 before fill(L,"1half", L2) contains:" << endl;
L2.print();
cout<<"calling fill(L,"1half", L2);"<
fill(L,"1half", L2);
cout << "List L after fill(L,"1half", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
cout << "List L before fill(L,"2half", L2) contains:" << endl;
L.print();
cout << "List L2 before fill(L,"2half", L2) contains:" << endl;
L2.print();
cout<<"calling fill(L,"2half", L2);"<
fill(L,"2half", L2);
cout << "List L after fill(L,"2half", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
L2.insertEnd(2);
L2.insertEnd(1);
L2.insertEnd(3);
L2.insertEnd(4);
L2.insertEnd(3);
L2.insertEnd(3);
L2.insertEnd(2);
cout << "List L before fill(L,"2half", L2) contains:" << endl;
L.print();
cout << "List L2 before fill(L,"2half", L2) contains:" << endl;
L2.print();
cout<<"calling fill(L,"2half", L2);"<
fill(L,"2half", L2);
cout << "List L after fill(L,"2half", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
cout << "List L before fill(L,"duplicate", L2) contains:" << endl;
L.print();
cout << "List L2 before fill(L,"duplicate", L2) contains:" << endl;
L2.print();
cout<<"calling fill(L,"duplicate", L2);"<
fill(L,"duplicate", L2);
cout << "List L after fill(L,"duplicate", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
L2.insertEnd(2);
L2.insertEnd(1);
L2.insertEnd(3);
L2.insertEnd(4);
L2.insertEnd(3);
L2.insertEnd(3);
L2.insertEnd(2);
cout << "List L before fill(L,"duplicate", L2) contains:" << endl;
L.print();
cout << "List L2 before fill(L,"duplicate", L2) contains:" << endl;
L2.print();
cout<<"calling fill(L,"duplicate", L2);"<
fill(L,"duplicate", L2);
cout << "List L after fill(L,"duplicate", L2) contains:" << endl;
L.print();
cout<
return 0;
}
//this nonmember func //
#include //Line 1
#include //Line 2
#include
#include "arrayListType.h" //Line
using namespace std; //Line 4
int main() //Line 5
{
arrayListType L(7),L2(7);
L.insertEnd(2);
L.insertEnd(1);
L.insertEnd(3);
L.insertEnd(4);
L.insertEnd(3);
L.insertEnd(3);
L.insertEnd(2);
cout << "List L before L.differentiate() contains:" << endl;
L.print();
cout<<"L.differentiate() = "<< L.differentiate()<
cout << "List L after L.differentiate() contains:" << endl;
L.print();
cout<
L.clearList();
L.insertEnd(2);
L.insertEnd(1);
L.insertEnd(3);
L.insertEnd(4);
L.insertEnd(3);
L.insertEnd(3);
L.insertEnd(2);
cout << "List L before L.averageEach2() contains:" << endl;
L.print();
cout<<"calling L.averageEach2()"<
L.averageEach2();
cout << "List L after L.averageEach2() contains:" << endl;
L.print();
cout<
L.clearList();
L.insertEnd(2);
L.insertEnd(1);
L.insertEnd(3);
L.insertEnd(4);
L.insertEnd(3);
L.insertEnd(3);
L.insertEnd(2);
cout << "List L before L.keepPalindrome() contains:" << endl;
L.print();
cout<<"calling L.keepPalindrome()"<
L.keepPalindrome();
cout << "List L after L.keepPalindrome() contains:" << endl;
L.print();
cout<
arrayListType cL(8);//a,c,d,f,f,g,c,z
cL.insertEnd('a');
cL.insertEnd('c');
cL.insertEnd('d');
cL.insertEnd('f');
cL.insertEnd('f');
cL.insertEnd('g');
cL.insertEnd('c');
cL.insertEnd('z');
cout << "List cL before cL.keepPalindrome() contains:" << endl;
cL.print();
cout<<"calling cL.keepPalindrome()"<
cL.keepPalindrome();
cout << "List cL after cL.keepPalindrome() contains:" << endl;
cL.print();
cout<
L2.clearList();
cout << "List L before L.fill("reverse", L2) contains:" << endl;
L.print();
cout << "List L2 before L.fill("reverse", L2) contains:" << endl;
L2.print();
cout<<"calling L.fill("reverse", L2);"<
L.fill("reverse", L2);
cout << "List L after L.fill("reverse", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
L2.insertEnd(2);
L2.insertEnd(1);
L2.insertEnd(3);
L2.insertEnd(4);
L2.insertEnd(3);
L2.insertEnd(3);
L2.insertEnd(2);
cout << "List L before L.fill("reverse", L2) contains:" << endl;
L.print();
cout << "List L2 before L.fill("reverse", L2) contains:" << endl;
L2.print();
cout<<"calling L.fill("reverse", L2);"<
L.fill("reverse", L2);
cout << "List L after L.fill("reverse", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
cout << "List L before L.fill("1half", L2) contains:" << endl;
L.print();
cout << "List L2 before L.fill("1half", L2) contains:" << endl;
L2.print();
cout<<"calling L.fill("1half", L2);"<
L.fill("1half", L2);
cout << "List L after L.fill("1half", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
L2.insertEnd(2);
L2.insertEnd(1);
L2.insertEnd(3);
L2.insertEnd(4);
L2.insertEnd(3);
L2.insertEnd(3);
L2.insertEnd(2);
cout << "List L before L.fill("1half", L2) contains:" << endl;
L.print();
cout << "List L2 before L.fill("1half", L2) contains:" << endl;
L2.print();
cout<<"calling L.fill("1half", L2);"<
L.fill("1half", L2);
cout << "List L after L.fill("1half", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
cout << "List L before L.fill("2half", L2) contains:" << endl;
L.print();
cout << "List L2 before L.fill("2half", L2) contains:" << endl;
L2.print();
cout<<"calling L.fill("2half", L2);"<
L.fill("2half", L2);
cout << "List L after L.fill("2half", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
L2.insertEnd(2);
L2.insertEnd(1);
L2.insertEnd(3);
L2.insertEnd(4);
L2.insertEnd(3);
L2.insertEnd(3);
L2.insertEnd(2);
cout << "List L before L.fill("2half", L2) contains:" << endl;
L.print();
cout << "List L2 before L.fill("2half", L2) contains:" << endl;
L2.print();
cout<<"calling L.fill("2half", L2);"<
L.fill("2half", L2);
cout << "List L after L.fill("2half", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
cout << "List L before L.fill("duplicate", L2) contains:" << endl;
L.print();
cout << "List L2 before L.fill("duplicate", L2) contains:" << endl;
L2.print();
cout<<"calling L.fill("duplicate", L2);"<
L.fill("duplicate", L2);
cout << "List L after L.fill("duplicate", L2) contains:" << endl;
L.print();
cout<
L2.clearList();
L2.insertEnd(2);
L2.insertEnd(1);
L2.insertEnd(3);
L2.insertEnd(4);
L2.insertEnd(3);
L2.insertEnd(3);
L2.insertEnd(2);
cout << "List L before L.fill("duplicate", L2) contains:" << endl;
L.print();
cout << "List L2 before L.fill("duplicate", L2) contains:" << endl;
L2.print();
cout<<"calling L.fill("duplicate", L2);"<
L.fill("duplicate", L2);
cout << "List L after L.fill("duplicate", L2) contains:" << endl;
L.print();
cout<
return 0;
}
Part 1: Starting from the arrayListType.h (attached with this assignment) and without using any of the predefined member functions or modifying them, write the required code to do the following. Make sure to perform all the required error checking. 1. Modify the arrayListType by adding a member function that keep the first element in the list as is and replace subsequent elements by the result of subtracting the element from the first element. This member function returns the first element in the list. For example, if the list L contains the elements 2,1,3,4,5,3,0 and you call the member function as in L.differentiate(); The list content will then be changed to 2,1,-1,-2,-3,-1,2 And the function returns 2. The list should not be empty.
Step by Step Solution
3.45 Rating (158 Votes )
There are 3 Steps involved in it
ifndef ARRAYLISTTYPE define ARRAYLISTTYPE include include using namespace std template class ... View full answer
Get step-by-step solutions from verified subject matter experts
