Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program 3: Create a class for working with set of numbers from 0 to 20.. A zero-one array should be declared as a private data

image text in transcribed
Program 3: Create a class for working with set of numbers from 0 to 20.. A zero-one array should be declared as a private data member. If element x is in the set, then alx] should be set to 1. If element x is not in the set, then a[x] should be set to 0. The following methods should be in your class. a. A default constructor that initializes the set to the null set. b. A method to allow the user to enter the values of a set. c. Find and store the union of two sets. d. Find and store the intersection of two sets. e. Find and store the difference of two sets. f. Print a set. g. Change a set to its complement. Your main should instantiate two sets and call each of the class methods. The two sets data should be entered and their union, intersection, and difference should be printed. Lastly, the two sets should be changed to their complements and printed again. (Please do not overload the operators for this program.) The union of set A and set B is the set of elements that are in set A or set B. For example, the union of the sets {2, 4, 5, 6} and {1, 4, 5, 7, 8, 9} is the set {1, 2, 4, 5, 6, 7, 8, 9} The intersection of set A and set B is the set of elements that are in set A and set B, that is the elements in common. For example, the intersection of the two sets {2, 4, 5, 6} and {1, 4, 5, 7, 8, 9} is {4, 5} The difference of set A and set B is those elements in set A that are not in set B. That is, remove the common elements from set A. The difference of the two sets {2, 4, 5, 6} and {1, 4, 5. 7,8, 9} is {2, 6} The complement of a set is those elements not within the set from the universe which is the integers 0 to 20 for this program. For example, the set of even integers from 0 to 20 has a complement of the odd integers from 0 to 20

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions