A C# console application that analyzes student enrollment in two courses using mathematical set operations. The system computes and displays the union, intersection, and complements of sets representing students enrolled in Course A, Course B, and the universal set of all registered students.
- Set A: Students enrolled in Course A
- Set B: Students enrolled in Course B
- Universal Set U: All registered students
- Union of A and B: Students in either course (20 marks)
- Intersection of A and B: Students in both courses (20 marks)
- Complement of A: Students not in Course A (20 marks)
- Complement of B: Students not in Course B (20 marks)
- No duplicate IDs in a single set
- Sets A and B are subsets of U
- Non-empty sets validation
- Results displayed in sorted, comma-separated format
- Clear, formatted presentation
- .NET 8.0 or later
- Command line interface
-
Navigate to the project directory:
cd SetOperationsSystem -
Build and run the application:
dotnet run
The application will prompt you to enter the universal set (all registered students):
Enter the universal set U (all registered students):
Enter student IDs separated by spaces (e.g., 1001 1002 1003):
Example Input: 1001 1002 1003 1004 1005 1006 1007 1008
Enter students enrolled in Course A:
Enter students enrolled in Course A:
Enter student IDs separated by spaces:
Example Input: 1001 1002 1003 1004
Enter students enrolled in Course B:
Enter students enrolled in Course B:
Enter student IDs separated by spaces:
Example Input: 1003 1004 1005 1006
=== Input Sets ===
Universal Set U = {1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008}
Set A (Course A) = {1001, 1002, 1003, 1004}
Set B (Course B) = {1003, 1004, 1005, 1006}
=== Set Operation Results ===
Union of A and B (students in either course) = {1001, 1002, 1003, 1004, 1005, 1006}
Intersection of A and B (students in both courses) = {1003, 1004}
Complement of A (students not in Course A) = {1005, 1006, 1007, 1008}
Complement of B (students not in Course B) = {1001, 1002, 1007, 1008}
- Student IDs: Must be integers
- No Duplicates: Each set must have unique student IDs
- Subset Rule: Course A and B must be subsets of Universal Set U
- Non-empty: All sets must contain at least one student
- Empty sets
- Duplicate student IDs within a set
- Student IDs not present in the universal set
- Non-numeric input
- Union (A ∪ B): All students in either Course A OR Course B
- Intersection (A ∩ B): Students in BOTH Course A AND Course B
- Complement (A'): Students in Universal Set U but NOT in Course A
- Complement (B'): Students in Universal Set U but NOT in Course B
- Universal Set U: {1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008}
- Set A: {1001, 1002, 1003, 1004}
- Set B: {1003, 1004, 1005, 1006}
Union A ∪ B: {1001, 1002, 1003, 1004, 1005, 1006} Intersection A ∩ B: {1003, 1004} Complement A': {1005, 1006, 1007, 1008} Complement B': {1001, 1002, 1007, 1008}
- Models: Student and Course classes
- Services: SetOperationsService with static methods
- Program: Main console application with input handling
Union(setA, setB): Computes union of two setsIntersection(setA, setB): Computes intersection of two setsComplement(set, universalSet): Computes complement of a setIsSubset(subset, universalSet): Validates subset relationshipHasNoDuplicates(students): Checks for duplicate IDsFormatSet(students): Formats output in sorted, comma-separated format
- Universal Set: 1001 1002 1003 1004 1005 1006 1007 1008
- Course A: 1001 1002 1003 1004
- Course B: 1003 1004 1005 1006
- Universal Set: 2001 2002 2003 2004 2005
- Course A: 2001 2002
- Course B: 2004 2005
The application includes comprehensive error handling for:
- Invalid numeric input
- Empty sets
- Duplicate student IDs
- Subset validation failures
- General exceptions
By using this application, you will understand:
- Set theory fundamentals
- Mathematical set operations
- Input validation techniques
- Error handling in C#
- Console application development
- Object-oriented programming principles
Author: NickiMash17
Project: C# Mathematical Applications - Practical Projects