Question: ONLY USE C++ language. REQUIRED. sample input and output shown at the end. Purpose: To demonstrate the ability to represent data, such as sets, using
ONLY USE C++ language. REQUIRED. sample input and output shown at the end.


Purpose: To demonstrate the ability to represent data, such as sets, using bit-strings and to perform the appropriate logical operations on those representations to compute the desired results. This program should be written in Java, C++, Python, or C. Discussion: A bit string is a sequence of bits used to store or represent values. In this case, each bit represents a digit from 0 to 9 . As a result, the bit position can be used as the value representation while the value represents whether that digit is a member of the set. For example, using a 16 bit integer to store our set, the binary representation of the set {0,3,5} would be: 00000000000101001 which would be the decimal integer value 41 . Note bits 0,3 , and 5 are all set to 1 , indicating set membership. For this assignment you will write a program that reads elements of a two sets from the keyboard and display the results of operations on those sets. Given subsets A and B of a universal set with 10 elements {0,1,2,3,4,5,6,7,8,9}, write a C, C++, or Java program that uses bit strings to find the results of set operations: complement, union, intersection, difference, and symmetric difference. You should refer to this document for help. Note: You must use integers to represent the sets. Things that are NOT integers: arrays of anything, strings, pre-defined library classes. You should declare one integer for the set A and one integer for the set B. Create one function/method for each operation to be performed. The program will be tested with the following pairs of set data: Set A={012345} Set B={3456789} Set A={3453} Set B={1234} Set A={02468} Set B={13579} Input should be read from prompts on the keyboard (which can be provided through input redirection). The number of elements in the set should come first, followed by list of elements in that set. Repeated elements should not cause problems and elements outside the appropriate range should generate an error message. Here is a sample program for Windows, you must run it on the command line, bitstring.exe The input portion of your program should look like: CS 2130 - Computational Structures Waldo Wildcat This program reads in the values of two sets and displays the results of several operations on the sets. Please enter the number of elements in set A : 3 Please enter element 1: 0 Please enter element 2: 23 Value entered is not allowed, please try again. Please enter element 2: 2 Please enter element 3: 9 Please enter the number of elements in set B: The sets may contain anywhere from zero to ten elements. You need to ensure the values entered are between 0 and 9 , but you should not test if a value has already been entered. Output results should be clearly displayed with appropriate labeling. An example of a typical output format is given here: Input Sets Set A={0,1,2} Set B={2,3,4} Complement of A={3,4,5,6,7,8,9} Union of A and B={0,1,2,3,4} Intersection of A and B={2} Difference of A and B={0,1} Symmetric Difference of A and B={0,1,3,4}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
