A. Please explain function studentType():
studentType::studentType()
{
numberOfCourses = 0;
sId = 0;
isTuitionPaid = false;
for (inti = 0; i < 6; i++)
coursesGrade[i] = '*';
}
B. Please explain function arrayListType() and :~arrayListType()
arrayListType::arrayListType(int size)
{
if (size <= 0)
{
cout << "The array size must be positive. Creating "
<< "an array of the size 100." << endl;
maxSize = 100;
}
else
maxSize = size;
length = 0;
list = new int[maxSize];
}
arrayListType::~arrayListType()
{
delete [] list;
}
C. Please explain function below:
arrayListType::arrayListType(const arrayListType&
otherList)
{
maxSize = otherList.maxSize;
length = otherList.length;
list = new int[maxSize]; //create the array
for (int j = 0; j < length; j++) //copy otherList
list [j] = otherList.list[j];
}
//A
studentType::studentType()
{
numberOfCourses = 0;//setting variables
sId = 0;
isTuitionPaid = false;
for (inti = 0; i < 6; i++)
coursesGrade[i] = '*';//setting six valus of coursesGrade array to
'*'
}
//B
//constructor
arrayListType::arrayListType(int size)
{
if (size <= 0)//if size is less than or equal to 0
{//then printing a message
cout << "The array size must be positive. Creating "
<< "an array of the size 100." << endl;
maxSize = 100;//and setting maxsize to 100
}
else//if greater than 0
maxSize = size;//setting max size
length = 0;
list = new int[maxSize];//creating array with size maxSize
}
//destructor
arrayListType::~arrayListType()
{
delete [] list;//free ing array memory
}
//C
//copies the list passed
arrayListType::arrayListType(const arrayListType&
otherList)
{
maxSize = otherList.maxSize;
length = otherList.length;
list = new int[maxSize]; //create the array
for (int j = 0; j < length; j++) //copy otherList
list [j] = otherList.list[j];
}
A. Please explain function studentType(): studentType::studentType() { numberOfCourses = 0; sId = 0; isTuitionPaid = false;...
The function retrieveAt of the class arrayListType is written as a void function. Rewrite this function so that it is written as a value returning function, returning the required item. If the location of the item to be returned is out of range, use the assert function to terminate the program. note: please give all code in c++ below is the class and implementation(a test program would be helpful in determining how to use it): class arrayListType { public: ...
This project is divided into 3 parts: Part 1. Create a new project and download the arrayList and unorderedArrayList templates that are attached. Create a header file for your unorderedSet template and add it to the project. An implementation file will not be needed since the the new class will be a template. Override the definitions of insertAt, insertEnd, and replaceAt in the unorderedSet template definition. Implement the template member functions so that all they do is verify that the...
A. Please explain function below: unorderedArrayListType::unorderedArrayListType(int size) : arrayListType(size) { } B. Please explain function below: voidunorderedArrayListType::remove(intremoveItem) { int loc; if (length == 0) cout << "Cannot delete from an empty list." << endl; else { loc = seqSearch(removeItem); if (loc != -1) removeAt(loc); else cout << "The item to be deleted is not in the list." << endl; } } C. Please explain function below: What is the output of the following code? int x = 0; int y...
/* Array expander: Write a function that accepts an int array as argument. The function should create a new array that is n times the size of the argument array, where n is a user input. The function should copy the contents of the argument array to the new array, and initialize the unused elements of the second array with 0. The function should return a pointer to the new array */ #include <iostream> using namespace std; const int NUM_ELEM...
Please help me finish my code. Before the final pause in the main function, create an ArrayList of another type such as double, char, short, bool, float, etc. Your choice. Add five data items to your array as we did for the int and string array lists. Print them out with a for loop as we did before. Print out the count and capacity of your new array list. Source.cpp #include #include #include #include "ArrayList.h" using namespace std; /// Entry...
9. At your job, you are creating a library. A co-worker brought this test code to you. They expect that the output would be "12 12 12 12 12". However, they are getting "Empty List" (a) Describe why the error is occurring. (b) Explain how to fix the code. #include <iostream> using namespace std; CON void increaseArray (int* array, int size, int value) { int newSize = size + 5; if (size ==0) { size = 5; O int* newArray...
C++ problem with dynamic arrays is that once the array is created using the new operator the size cannot be changed. For example, you might want to add or delete entries from the array similar to the behavior of a vector. This project asks you to create a class called DynamicStringArray that includes member functions that allow it to emulate the behavior of a vector of strings. The class should have: A private member variable called dynamicArray that references a...
#include <iostream> #include <fstream> using namespace std; //constants const int CAP = 100; //function prototypes bool openFile(ifstream &); void readData(ifstream &, int [], int &); void printData(const int [], int); void sum(const int[], int); void removeItem(int[], int &, int); int main() { ifstream inFile; int list[CAP], size = 0; if (!openFile(inFile)) { cout << "Program terminating!! File not found!" << endl; return -1; } //read the data from the file readData(inFile, list, size); inFile.close(); cout << "Data in file:" <<...
c++ /*This is the starter file for your final proficiency test This program has a function that will generate a list of integers using the rand function. Your job is to fill the insertNum and oddCount functions.*/ #include <iostream> #include <ctime> using namespace std; //constants and function prototypes const int CAP = 100; int buildList(int[], int size); void printList(int[], int size); //your functions to implement /*This function finds even numbers in the list, and inserts a number before the even...