You are probably familiar with the basics of set theory. For this project we only need to remember the following:
Your program must prompt an interface for the user. It should be like this:
***************Set Calculation*********************
Options:
A. Input Set A
B. Input Set B
C. Cartesian product
D. Difference
I. Inclusion
U. Union
N. Intersection
H. Help
Q. Quit
***************************************************
Then, the user will be able to choose an option from these 9 options (A, B, C, D, I, U, N, H, Q). Invalid inputs should be detected and prompt a warning message -- "Invalid option!". By selecting option
A and option B, the user should be able to input the set A and set B. Since each element in these two sets should be an interger. Invalid input should also be detected and under this condition, the content of the corresponding set should be set to empty.
If the operation is Union, Intersection, or Difference, you have to print the resulting
set in an ascending order when the operation is applied on
and
. If the operation is Cartesian product, you should print the corresponding results in an ascending order with respect to A and B. If the relation is Inclusion,
then you have to print TRUE if
,
and FALSE otherwise.
It is possible that the input sets
and
may have repeated elements. For example,
the following set is allowed:
A={23, 56, 87, 23}. It may be the case
that there are elements in
that are also in
. For example,
and
. However, the output of your program cannot have any
repeated element. So, in this case, the union of the two sets
is
, but should not be:
. It may be possible that A={23, 23}, and B={23, 76}. Then, if the user choose I(Inclusion), the program should prompt "Yes. Set A is included in Set B.".
You can assume that the integers in a set will range from 0
to
, and you can also assume that the largest number of elements in A or B is 50.
Example Input (The lines marked in red denote the user input):
lore 10 % ls Makefile project3.c lore 11 % make gcc project3.c -o project3.out lore 12 % project3.out ***************Set Calculation*********************
Options:
A. Input Set A
B. Input Set B
C. Cartesian product
D. Difference
I. Inclusion U. Union
N. Intersection
H. Help
Q. Quit
***************************************************
Please choose an option:
A
Please input Set A
23 46 98 79 23 46
Please choose an option:
B
Please input set B
90 23 76 13 65 43 46
Please choose an option:
C
The cartesian product of A and B is: (23, 13) (23, 23) (23, 43) (23, 46) (23, 65) (23, 76) (23, 90) (46, 13) (46, 23) (46, 43) (46, 46) (46, 65) (46, 76) (46, 90) (79, 13) (79, 23) (79, 43) (79, 46) (79, 65) (79, 76) (79, 90) (98, 13) (98, 23) (98, 43) (98, 46) (98, 65) (98, 76) (98, 90)
Please choose an option:
U
A U B equals: 13 23 43 46 65 76 79 90 98
Please choose an option:
N
A N B equals: 23 46
Please choose an option:
D
A - B equals: 79 98
Please choose an option:
I
No. Set A is not included in Set B
Please choose an option:
H
***************Set Calculation*********************
Options:
A. Input Set A
B. Input Set B
C. Cartesian product
D. Difference
I. Inclusion
U. Union
N. Intersection
H. Help
Q. Quit
***************************************************
Please choose an option:
A
Please input set A
23 76 23
Please choose an option:
B
Please input set B 87 we3
Invalid Input!
Please choose an option:
U
A U B equals: 23 76
Please choose an option:
B
Please input set B
90 65 23 76 98 98
Please choose an option:
I
Yes. Set A is included in Set B
Please choose an option:
W
Invalide Option!
Please choose an option: Q
lore 12 %
When you are satisfied that your program works correctly (or you run out of time), please do the following.
turnin -c cs240=XXXX -p project3 project3
where XXXX represents your lab section number.
The turnin section should be as follows:
| Section | Time | TA |
| 0201 | Thursday 15:30-17:20 | Dan Zhang |
| 0301 | Friday 09:30-11:20 | Suli Xi |
| 0401 | Friday 13:30-15:20 | Youhan Fang |
| 0501 | Thursday 09:30-11:20 | J.C.Chin |
Make sure turnin reports that your project was submitted for grading. You can check the files you have submitted by running the following command:
turnin -c cs240=XXXX -v -p project3
| 5 points | Makefile created and submitted |
| 5 points | Program can quit successfully |
| 10 points | Interface, Error Detection |
| 80 points | 10 test cases |