Question

Hi I need a fix in my program. The program needs to finish after serving the customers from the queue list.

Requeriments:

Create a struct to represent a customer object. Include these data members: (1) an ID tag as explained below and (2) service end time. Service end time is the whole number clock time that the customers service is scheduled to end -- its calculated when their service begins, as explained later. . The ID tag for the customer is a single letter of the alphabet, A-Z. Assign A to the first-created customer, B to the next, and so on. After the 26th customer is assigned Z, start the IDs over again that is, assign A to the 27th customer. Use the Q&A section of the module to share ideas of how to manage this. Customers arrive at the specified average arrival rate from the beginning of the simulation until the specified clock time at which new arrivals stop. After that time there are no new arrivals, but the simulation continues, allowing the wait queue to empty and the servers to become idle Read 6 input values from a text file simulation.txt that you will write -- one value per line. Do NOT submit this file Use a queue object to represent the wait queue. The queue should store customer objects. Create the nowServing array of customer objects to represent the customers being served. When a customer is removed from the wait queue, youll copy that customer to the nowServing array. Include another corresponding array of boolean values, whose value is true if the server at that index position is busy serving a customer, false otherwise, indicating that the server is idle. (Theres more than one way to accomplish this, so use a different way if you wish). Use your MyDynamicArray and submit its H file with your solution without modification. As soon as a customer starts being helped by a server, the service time interval is determined as a random number in the range from the minimum service time interval to the maximum service time interval. Add the randomly-determined service time interval to the current clock time to compute the future clock time when ervice will end. The possible values for service time interval are whole numbers between the minimum service time and maximum service time, inclusive, all equally likely. If the minimum service time and maximum service time are the same, the service time interval is always the same. If the minimum service time is 1 and the maximum service time is 6, the possible service times are 1, 2, 3, 4, 5, and 6 all equally

Headers:

DynamicArray.h

#ifndef DynamicArray_h

#define DynamicArray_h

#include

using namespace std;

template

class DynamicArray

{

V* values;

int cap;

V dummy;

public:

DynamicArray(int = 2);

DynamicArray(const DynamicArray&);

~DynamicArray() { delete[] values; }

int capacity() const { return cap; }

void capacity(int);

V operator[](int) const;

V& operator[](int);

DynamicArray& operator=(const DynamicArray&);

};

template

DynamicArray::DynamicArray(int cap)

{

this->cap = cap;

values = new V[cap];

for (int index = 0; index < cap; index++) {

values[index] = V();

}

}

template

V DynamicArray::operator[](int index) const

{

if (index < 0 || index >= cap)

return V(); // a copy

return values[index]; // a copy

}

template

V& DynamicArray::operator[](int index)

{

if (index < 0) {

return dummy; // a copy

}

else if (index >= cap) {

capacity(2 * index);

}

return values[index]; // a copy

}

template

void DynamicArray::capacity(int newCap) {

V* temp = new V[newCap];

// get the lesser of the new and old capacities

int limit = min(newCap, cap);

// copy the contents

for (int i = 0; i < limit; i++) {

temp[i] = values[i];

}

// set added values to their defaults

for (int i = limit; i < cap; i++) {

temp[i] = V();

}

// deallocate original array

delete[] values;

// switch newly allocated array into the object

values = temp;

// update the capacity

cap = newCap;

}

template

DynamicArray::DynamicArray(const DynamicArray& original)

{

cap = original.cap; // still copy

values = new V[cap]; // not copy, is new

for (int i = 0; i < cap; i++) { // contents copy original to new

values[i] = original.values[i];

}

}

template

DynamicArray& DynamicArray::operator=(const DynamicArray& original)

{

if (this != &original) //check if copy or not, better not be tho

{

// same as destructor

delete[] values;

// same as copy constructor

cap = original.cap;

values = new V[cap]; // not copy, is new

for (int i = 0; i < cap; i++) { // contents copy original to new

values[i] = original.values[i];

}

}

return *this; // return self reference

}

#endif

Queue.h

#ifndef QUEUE_QUEUE_H //checks if 'QUEUE_QUEUE_H' has been defined

#define QUEUE_QUEUE_H //define 'QUEUE_QUEUE_H' to use in the program

template //use a template class called 'V'

class Queue //class Queue

{

struct Node

{

V value;

Node* next;

};

Node* firstNode; //head pointer to the first node

int siz = 0; //variable necessary to trak the number of nodes

Node* lastNode; //necssary to create a private data member

public:

Queue(); // may have a defaulted parameter, tested

void push(const V&);

V& front(); // return a mutable reference to the oldest node

V& back(); // return a mutable reference to the newest node

void pop(); // remove the oldest node

int size() const { return siz; } //return the values of the size

bool empty() const { return siz == 0; } //neccesary to empty the values

void clear(); //necessary to clear the values

~Queue() { clear(); }

Queue& operator=(const Queue&);

Queue(const Queue&);

};

template

Queue::Queue()

{

lastNode = 0;

siz = 0;

}

//function to push the values from the stack

template

void Queue::push(const V& value)

{

Node* temp = new Node{ value }; // C++11

if (lastNode) lastNode->next = temp;

else firstNode = temp;

lastNode = temp;

++siz;

}

//template to put the values to the front of the stack

template

V& Queue::front()

{

return firstNode->value;

}

//function necessary to put the values on the back of the stack

template

V& Queue::back() {

return lastNode->value;

}

//function necessary to pop the values fromn the stack

template

void Queue::pop()

{

if (firstNode)

{

Node* p = firstNode;

firstNode = firstNode->next;

delete p;

--siz;

}

if (siz == 0)

{

lastNode = 0;

}

}

//function necessary to clear the values from the stack

template

void Queue::clear()

{

while (firstNode)

{

Node* p = firstNode;

firstNode = firstNode->next;

delete p;

--siz;

}

lastNode = 0;

}

//function necessary to copy the values

template

Queue::Queue(const Queue& original)

{

firstNode = 0;

lastNode = 0; // temporary tail

siz = original.siz;

for (Node* p = original.firstNode; p; p = p->next)

{

Node* temp = new Node;

temp->value = p->value;

temp->next = 0;

if (lastNode) lastNode->next = temp;

else firstNode = temp;

lastNode = temp;

}

}

//function necessary to create values if they are not stored in the original queue

template

Queue& Queue::operator=(const Queue& original)

{

if (this != &original)

{

// deallocate existing list

while (firstNode)

{

Node* p = firstNode->next;

delete firstNode;

firstNode = p;

}

// build new queue

lastNode = 0; // temporary tail

for (Node* p = original.firstNode; p; p = p->next)

{

Node* temp = new Node;

temp->value = p->value;

temp->next = 0;

if (lastNode) lastNode->next = temp;

else firstNode = temp;

lastNode = temp;

}

siz = original.siz;

}

return *this;

}

#endif

Code:

#include

#include

#include

#include

using namespace std;

#include

#include

#include "MyDynamicArray.h"

#include "MyQueue.h"

struct Customer {

char ID;

int arrivalT;

int endT;

};

int getRandomNumberOfArrivals(double);

char genID(char&);

int randTimeAdd(int, int);

int main()

{

srand(time(0));

rand();

int numServers = 0, waitMaxLength = 0, minServTime = 0, maxServTime = 0, clockStopTime = 0;

double avgArrivalRate = 0.5;

char curAlpha = 'A';

ifstream fin;

fin.open("simulation.txt");

int switchCount = 0;

while (fin.good()) {

string input;

getline(fin, input);

switch (switchCount)

{

case 0:

numServers = atoi(input.c_str());

cout << "number of servers: " << numServers << endl;

break;

case 1:

avgArrivalRate = atof(input.c_str());

break;

case 2:

waitMaxLength = atoi(input.c_str());

cout << "maximum queue length: " << waitMaxLength << endl;

break;

case 3:

minServTime = atoi(input.c_str());

cout << "minimum service time: " << minServTime << " minutes" << endl;

break;

case 4:

maxServTime = atoi(input.c_str());

cout << "maximum service time: " << maxServTime << " minutes" << endl;

break;

case 5:

clockStopTime = atoi(input.c_str());

cout << "customer arrival rate: " << avgArrivalRate << " per minute, for " << clockStopTime << " minutes" << endl;

break;

default:

throw("UH OH - PROBLEM");

}

switchCount++;

}

Queue custQ;

DynamicArray nowServing;

DynamicArray serversStatus;

for (int time = 0; ; time++) {

// handle all services scheduled to complete at this clock time

for (int i = 0; i < numServers; i++) {

if (serversStatus[i]) { //means is busy

if (nowServing[i].endT == time) {

serversStatus[i] = false;

}

}

}

// handle new arrivals -- can be turned away if wait queue is at maximum length!

if (time < clockStopTime) {

int numArrive = getRandomNumberOfArrivals(avgArrivalRate);

for (int i = 0; i < numArrive; i++) {

if (custQ.size() < waitMaxLength) {

Customer c;

c.ID = genID(curAlpha);

c.arrivalT = time;

custQ.push(c);

}

}

}

// for idle servers, move customer from wait queue and begin

for (int i = 0; i < numServers; i++) {

if (!serversStatus[i] && !custQ.empty()) {

nowServing[i] = custQ.front();

custQ.pop();

nowServing[i].endT = time + randTimeAdd(minServTime, maxServTime);

serversStatus[i] = true;

}

}

//output the summary

//output the current time

//output a visual representation of the servers and the wait queue

cout << "\nTime: " << time << endl;

cout << "---------------------------" << endl;

cout << "server now serving wait queue" << endl;

cout << "------ ----------- ----------" << endl;

for (int i = 0; i < numServers; i++) {

string show = " ";

if (serversStatus[i]) {

show = nowServing[i].ID;

}

cout << setw(2) << i << setw(10) << show;

if (i == 0) {

Queue tempQ = custQ;

cout << setw(10);

while (!tempQ.empty()) {

cout << tempQ.front().ID;

tempQ.pop();

}

}

cout << endl;

}

int numIdle = 0;

for (int i = 0; i < numServers; i++) {

if (!serversStatus[i]) {

numIdle++;

}

}

if (numIdle == numServers && time >= clockStopTime) {

break;

}

do {

cout << '\n' << "Press ENTER to continue...";

} while (cin.get() != '\n');

}

system("pause");

}

int randTimeAdd(const int a, const int b) {

return a + (rand() % b);

}

char genID(char& curAlpha) {

if (curAlpha == 'Z') {

curAlpha = 'A';

return 'Z';

}

return curAlpha++;

}

int getRandomNumberOfArrivals(double averageArrivalRate) {

int arrivals = 0;

double probOfnArrivals = exp(-averageArrivalRate);

for (double randomValue = (double)rand() / RAND_MAX;

(randomValue -= probOfnArrivals) > 0.0;

probOfnArrivals *= averageArrivalRate / static_cast(++arrivals));

return arrivals;

}

txt file

4
2.5
8
3
10
50

0 0
Add a comment Improve this question Transcribed image text
Answer #1

DynamicArray.h

#ifndef DynamicArray_h

#define DynamicArray_h

// #include

using namespace std;

template <class V>

class DynamicArray

{

V *values;

int cap;

V dummy;

public:

DynamicArray(int = 2);

DynamicArray(const DynamicArray &);

~DynamicArray() { delete[] values; }

int capacity() const { return cap; }

void capacity(int);

V operator[](int) const;

V &operator[](int);

DynamicArray &operator=(const DynamicArray &);

};

template <class V>

DynamicArray<V>::DynamicArray(int cap)

{

this->cap = cap;

values = new V[cap];

for (int index = 0; index < cap; index++)

{

values[index] = V();

}

}

template <class V>

V DynamicArray<V>::operator[](int index) const

{

if (index < 0 || index >= cap)

return V(); // a copy

return values[index]; // a copy

}

template <class V>

V &DynamicArray<V>::operator[](int index)

{

if (index < 0)

{

return dummy; // a copy

}

else if (index >= cap)

{

capacity(2 * index);

}

return values[index]; // a copy

}

template <class V>

void DynamicArray<V>::capacity(int newCap)

{

V *temp = new V[newCap];

// get the lesser of the new and old capacities

int limit = min(newCap, cap);

// copy the contents

for (int i = 0; i < limit; i++)

{

temp[i] = values[i];

}

// set added values to their defaults

for (int i = limit; i < cap; i++)

{

temp[i] = V();

}

// deallocate original array

delete[] values;

// switch newly allocated array into the object

values = temp;

// update the capacity

cap = newCap;

}

template <class V>

DynamicArray<V>::DynamicArray(const DynamicArray &original)

{

cap = original.cap; // still copy

values = new V[cap]; // not copy, is new

for (int i = 0; i < cap; i++)

{ // contents copy original to new

values[i] = original.values[i];

}

}

template <class V>

DynamicArray<V> &

DynamicArray<V>::operator=(const DynamicArray &original)

{

if (this != &original) //check if copy or not, better not be tho

{

// same as destructor

delete[] values;

// same as copy constructor

cap = original.cap;

values = new V[cap]; // not copy, is new

for (int i = 0; i < cap; i++)

{ // contents copy original to new

values[i] = original.values[i];

}

}

return *this; // return self reference

};

#endif

Queue.h

#ifndef QUEUE_QUEUE_H //checks if 'QUEUE_QUEUE_H' has been defined

#define QUEUE_QUEUE_H //define 'QUEUE_QUEUE_H' to use in the program

template <class V> //use a template class called 'V'

class Queue //class Queue

{

struct Node

{

V value;

Node *next;

};

Node *firstNode; //head pointer to the first node

int siz; //variable necessary to trak the number of nodes

Node *lastNode; //necssary to create a private data member

public:

Queue(); // may have a defaulted parameter, tested

void push(const V &);

V &front(); // return a mutable reference to the oldest node

V &back(); // return a mutable reference to the newest node

void pop(); // remove the oldest node

int size() const { return siz; } //return the values of the size

bool empty() const { return siz == 0; } //neccesary to empty the values

void clear(); //necessary to clear the values

~Queue() { clear(); }

Queue &operator=(const Queue &);

Queue(const Queue &);

};

template <class V>

Queue<V>::Queue()

{

lastNode = 0;

siz = 0;

}

//function to push the values from the stack

template <class V>

void Queue<V>::push(const V &value)

{

Node *temp = new Node; // C++11

temp->value = value;

if (lastNode)

lastNode->next = temp;

else

firstNode = temp;

lastNode = temp;

++siz;

}

//template to put the values to the front of the stack

template <class V>

V &Queue<V>::front()

{

return firstNode->value;

}

//function necessary to put the values on the back of the stack

template <class V>

V &Queue<V>::back()

{

return lastNode->value;

}

//function necessary to pop the values fromn the stack

template <class V>

void Queue<V>::pop()

{

if (firstNode)

{

Node *p = firstNode;

firstNode = firstNode->next;

delete p;

--siz;

}

if (siz == 0)

{

lastNode = 0;

}

}

//function necessary to clear the values from the stack

template <class V>

void Queue<V>::clear()

{

while (firstNode)

{

Node *p = firstNode;

firstNode = firstNode->next;

delete p;

--siz;

}

lastNode = 0;

}

//function necessary to copy the values

template <class V>

Queue<V>::Queue(const Queue &original)

{

firstNode = 0;

lastNode = 0; // temporary tail

siz = original.siz;

for (Node *p = original.firstNode; p; p = p->next)

{

Node *temp = new Node;

temp->value = p->value;

temp->next = 0;

if (lastNode)

lastNode->next = temp;

else

firstNode = temp;

lastNode = temp;

}

}

//function necessary to create values if they are not stored in the original queue

template <class V>

Queue<V> & Queue<V>::operator=(const Queue &original)

{

if (this != &original)

{

// deallocate existing list

while (firstNode)

{

Node *p = firstNode->next;

delete firstNode;

firstNode = p;

}

// build new queue

lastNode = 0; // temporary tail

for (Node *p = original.firstNode; p; p = p->next)

{

Node *temp = new Node;

temp->value = p->value;

temp->next = 0;

if (lastNode)

lastNode->next = temp;

else

firstNode = temp;

lastNode = temp;

}

siz = original.siz;

}

return *this;

};

#endif

main.cpp

#include <iostream>

#include <string>

#include <ctime>

#include <fstream>

#include <cstdlib>

#include <iomanip>

#include <cmath>

using namespace std;

// #include

// #include

#include "DynamicArray.h"

#include "Queue.h"

struct Customer

{

char ID;

int arrivalT;

int endT;

};

int getRandomNumberOfArrivals(double);

char genID(char &);

int randTimeAdd(int, int);

int main()

{

srand(time(0));

rand();

int numServers = 0, waitMaxLength = 0, minServTime = 0, maxServTime = 0, clockStopTime = 0;

double avgArrivalRate = 0.5;

char curAlpha = 'A';

ifstream fin;

fin.open("simulation.txt");

int switchCount = 0;

while (fin.good())

{

string input;

getline(fin, input);

switch (switchCount)

{

case 0:

numServers = atoi(input.c_str());

cout << "number of servers: " << numServers << endl;

break;

case 1:

avgArrivalRate = atof(input.c_str());

break;

case 2:

waitMaxLength = atoi(input.c_str());

cout << "maximum queue length: " << waitMaxLength << endl;

break;

case 3:

minServTime = atoi(input.c_str());

cout << "minimum service time: " << minServTime << " minutes" << endl;

break;

case 4:

maxServTime = atoi(input.c_str());

cout << "maximum service time: " << maxServTime << " minutes" << endl;

break;

case 5:

clockStopTime = atoi(input.c_str());

cout << "customer arrival rate: " << avgArrivalRate << " per minute, for " << clockStopTime << " minutes" << endl;

break;

default:

throw("UH OH - PROBLEM");

}

switchCount++;

}

Queue<Customer> custQ;

DynamicArray<Customer> nowServing;

DynamicArray<int> serversStatus;

for (int time = 0;; time++)

{

// handle all services scheduled to complete at this clock time

for (int i = 0; i < numServers; i++)

{

if (serversStatus[i])

{ //means is busy

if (nowServing[i].endT == time)

{

serversStatus[i] = false;

}

}

}

// handle new arrivals -- can be turned away if wait queue is at maximum length!

if (time < clockStopTime)

{

int numArrive = getRandomNumberOfArrivals(avgArrivalRate);

for (int i = 0; i < numArrive; i++)

{

if (custQ.size() < waitMaxLength)

{

Customer c;

c.ID = genID(curAlpha);

c.arrivalT = time;

custQ.push(c);

}

}

}

// for idle servers, move customer from wait queue and begin

for (int i = 0; i < numServers; i++)

{

if (!serversStatus[i] && !custQ.empty())

{

nowServing[i] = custQ.front();

custQ.pop();

nowServing[i].endT = time + randTimeAdd(minServTime, maxServTime);

serversStatus[i] = true;

}

}

//output the summary

//output the current time

//output a visual representation of the servers and the wait queue

cout << "\nTime: " << time << endl;

cout << "---------------------------" << endl;

cout << "server now serving wait queue" << endl;

cout << "------ ----------- ----------" << endl;

for (int i = 0; i < numServers; i++)

{

string show = " ";

if (serversStatus[i])

{

show = nowServing[i].ID;

}

cout << setw(2) << i << setw(10) << show;

if (i == 0)

{

Queue<Customer> tempQ = custQ;

cout << setw(10);

while (!tempQ.empty())

{

cout << tempQ.front().ID;

tempQ.pop();

}

}

cout << endl;

}

int numIdle = 0;

for (int i = 0; i < numServers; i++)

{

if (!serversStatus[i])

{

numIdle++;

}

}

if (numIdle == numServers && time >= clockStopTime)

{

break;

}

do

{

cout << '\n'

<< "Press ENTER to continue...";

} while (cin.get() != '\n');

}

system("pause");

}

int randTimeAdd(const int a, const int b)

{

return a + (rand() % b);

}

char genID(char &curAlpha)

{

if (curAlpha == 'Z')

{

curAlpha = 'A';

return 'Z';

}

return curAlpha++;

}

int getRandomNumberOfArrivals(double averageArrivalRate)

{

int arrivals = 0;

double probOfnArrivals = exp(-averageArrivalRate);

for (double randomValue = (double)rand() / RAND_MAX;

(randomValue -= probOfnArrivals) > 0.0;

probOfnArrivals *= averageArrivalRate / static_cast<int>(++arrivals))

;

return arrivals;

}Crkv-sdcQlocalhost DynanicArray]$ g++ nain.cpp Crkv-sdcQlocalhost DynanicArray]$ ./a. out nunber of servers: 4 naxinun queue

Add a comment
Know the answer?
Add Answer to:
Hi I need a fix in my program. The program needs to finish after serving the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need to complete the C++ program for hotel reservation. In the main cpp you have...

    I need to complete the C++ program for hotel reservation. In the main cpp you have to display the hotel information from the hotel.txt based on customer preferences(which can be taken from the User.txt) For example, if the customer's budget is 200$, then only the hotels with prices below that amount should be displayed. Then the user has an option to choose which one to reserve for the particular time(which also can be found in the user.txt) The last two...

  • A library maintains a collection of books. Books can be added to and deleted from and...

    A library maintains a collection of books. Books can be added to and deleted from and checked out and checked in to this collection. Title and author name identify a book. Each book object maintains a count of the number of copies available and the number of copies checked out. The number of copies must always be greater than or equal to zero. If the number of copies for a book goes to zero, it must be deleted from the...

  • Hello, I have some errors in my C++ code when I try to debug it. I...

    Hello, I have some errors in my C++ code when I try to debug it. I tried to follow the requirements stated below: Code: // Linked.h #ifndef INTLINKEDQUEUE #define INTLINKEDQUEUE #include <iostream> usingnamespace std; class IntLinkedQueue { private: struct Node { int data; Node *next; }; Node *front; // -> first item Node *rear; // -> last item Node *p; // traversal position Node *pp ; // previous position int size; // number of elements in the queue public: IntLinkedQueue();...

  • Requirements: Finish all the functions which have been declared inside the hpp file. Details: st...

    Requirements: Finish all the functions which have been declared inside the hpp file. Details: string toString(void) const Return a visible list using '->' to show the linked relation which is a string like: 1->2->3->4->5->NULL void insert(int position, const int& data) Add an element at the given position: example0: 1->3->4->5->NULL instert(1, 2); 1->2->3->4->5->NULL example1: NULL insert(0, 1) 1->NULL void list::erase(int position) Erase the element at the given position 1->2->3->4->5->NULL erase(0) 2->3->4->5->NULL //main.cpp #include <iostream> #include <string> #include "SimpleList.hpp" using std::cin; using...

  • The program I wrote has a few memory leaks. My assignment is to just fix the...

    The program I wrote has a few memory leaks. My assignment is to just fix the memory leaks. Here's the code: bool RemoveTail() { if (tail == nullptr) return false; Node *ptr = tail; if(tail->prev != nullptr) { tail = tail->prev; tail->next = nullptr; } else { tail = nullptr; head = nullptr; } delete ptr; ptr = nullptr; length--; return true; } bool RemoveAt(const unsigned int index) { if(index >= length || index < 0) return false; unsigned int...

  • Hi there! I need to fix the errors that this code is giving me and also...

    Hi there! I need to fix the errors that this code is giving me and also I neet to make it look better. thank you! #include <iostream> #include <windows.h> #include <ctime> #include <cstdio> #include <fstream> // file stream #include <string> #include <cstring> using namespace std; const int N=10000; int *freq =new int [N]; int *duration=new int [N]; char const*filename="filename.txt"; int songLength(140); char MENU(); // SHOWS USER CHOICE void execute(const char command); void About(); void Save( int freq[],int duration[],int songLength); void...

  • howthe   output   of   the   following   4   program segments (a)    const int SIZE=8;    int values[SIZE]...

    howthe   output   of   the   following   4   program segments (a)    const int SIZE=8;    int values[SIZE] = {10, 10, 14, 16, 6, 25, 5, 8};    int index;    index=0;    res = values[index];    for (int j=1; j<SIZE; j++)    {        if (values[j] > res)        {            res = values[j];            index = j;        cout << index << res << endl;        }    }    cout <<...

  • Hi I got error C2660 : 'valuein' : function does not take 2 parameters in visual...

    Hi I got error C2660 : 'valuein' : function does not take 2 parameters in visual studio 2013 this is my code so far #include <cstdlib> #include <list> #include <iostream> using namespace std; struct node {    int data;    node* next; }; void initialize(node*p); void insert(int data,int n); void remove(int b,int pos); bool empty(node*); void length(); bool valuein(int c); int reportvalue(int value); void ptintlist(); int menu(); int main() {    struct node*head=NULL;    char commands;    int value;   ...

  • C++ problem with dynamic arrays is that once the array is created using the new operator...

    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...

  • When running the program at the destructor  an exception is being thrown. Can someone help me out?...

    When running the program at the destructor  an exception is being thrown. Can someone help me out? vararray.h: #ifndef VARARRAY_H_ #define VARARRAY_H_ class varArray { public:    varArray(); // void constructor    int arraySize() const { return size; } // returns the size of the array    int check(double number); // returns index of element containg "number" or -1 if none    void addNumber(double); // adds number to the array    void removeNumber(double); // deletes the number from the array   ...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT