Question: Anyone can make this program work properly? Below code should make the output like the pictures. (Yet, it stop at before showing Union of A

Anyone can make this program work properly?

Below code should make the output like the pictures. (Yet, it stop at before showing "Union of A and B is" )

(( It does not have to use below code that I broguht, but main.cpp))

Thank you!

===================

// Integerset.h

===================

#ifndef INTEGERSET_H

#define INTEGERSET_H

#include

#include

using namespace std;

class IntegerSet

{

public:

IntegerSet();

IntegerSet(int arr[],int size);

IntegerSet& unionOfSets(const IntegerSet &other);

IntegerSet& intersectionOfSets(const IntegerSet &other);

void insertElement(int k);

void deleteElement(int k);

void printSet();

bool isEqualTo(const IntegerSet &other);

void inputSet();

private:

vector values ;

};

#endif

/

===================

// IntegerSet.cpp

===================

#include "IntegerSet.h"

IntegerSet::IntegerSet()

{

values = vector(101,false);

}

IntegerSet::IntegerSet(int arr[], int size)

{

values = vector(101,false);

for(int i=0;i

{

if(arr[i] >=0 && arr[i]

{

values[i] = true;

}

}

}

IntegerSet& IntegerSet:: unionOfSets(const IntegerSet &other)

{

IntegerSet unionSet;

for(size_t i=0;i

if(values[i])

unionSet.values[i] = true;

for(size_t i=0;i

if(other.values[i])

unionSet.values[i] = true;

return unionSet;

}

IntegerSet& IntegerSet::intersectionOfSets(const IntegerSet &other)

{

IntegerSet intersectionSet;

for(size_t i=0;i

if(values[i] && other.values[i])

intersectionSet.values[i] = true;

return intersectionSet;

}

void IntegerSet::insertElement(int k)

{

if(k>=0 && k

{

values[k] = true;

}

}

void IntegerSet::deleteElement(int k)

{

if(k>=0 && k

{

values[k] = false;

}

}

void IntegerSet::printSet()

{

bool empty = true;

cout

for(size_t i=0;i

{

if(values[i])

{

empty = false;

cout

}

}

if(empty)

cout

else

cout

}

bool IntegerSet:: isEqualTo(const IntegerSet &other)

{

bool equal = true;

for(size_t i=0;i

{

if(values[i] != other.values[i])

equal = false;

}

return equal;

}

void IntegerSet:: inputSet()

{

int k;

while(true)

{

cout

cin>>k;

if(k == -1)

{

cout

break;

}

if(k100)

cout

else

values[k] = true;

}

}

===================

// main.cpp

===================

#include #include "IntegerSet.h" using namespace std;

int main() { IntegerSet a; IntegerSet b; IntegerSet c; IntegerSet d;

cout

if ( a.isEqualTo( b ) ) cout

cout

cout

const int arraySize = 10; int intArray[ arraySize ] = { 25, 67, 2, 9, 99, 105, 45, -5, 100, 1 }; IntegerSet e( intArray, arraySize );

cout

cout

system("PAUSE"); return 0; } // end main

Anyone can make this program work properly? Below code should make the

output like the pictures. (Yet, it stop at before showing "Union of

A and B is" ) (( It does not have to use

Enter set A: Enter an element (-1 to end): 1 Enter an element (-1 to end): 5 Enter an element (-1 to end): 4 Enter an element (-1 to end): 7 Enter an element (-1 to end) 8 Enter an element (-1 to end) 2 Enter an element (-1 to end) -1 Entry complete Enter set B Enter an element (-1 to end): 20 Enter an element (-1 to end): 1 Enter an element (-1 to end): 5 Enter an element (-1 to end): 8 Enter an element (-1 to end): 12 Enter an element (-1 to end): 15 Enter an element (-1 to end): 18 Enter an element (-1 to end): 7 Enter an element (-1 to end): 30 Enter an element (-1 to end): 32 Enter an element (-1 to end): -1 Entry complete

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 Databases Questions!