Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help in JAVA !!! I have found same question in chegg solved in different way and I tried so many of them but

I need help in JAVA !!! I have found same question in chegg solved in different way and I tried so many of them but none of them are working. I am using netbean compiler. Please indicate that if I need to use 2 file for that problem, one is for class methods and another is for class main or if I can use one single file for that problem. Also, attached the screenshot of the output.

here is my problem

- Create class IntegerSet. Each IntegerSet object can hold integers in the range 0100. The set is represented by an array of booleans. Array element a[i] is true if integer i is in the set. Array element a[j] is false if integer j is not in the set. The no-argument constructor initializes the array to the empty set (i.e., all false values).

Provide the following methods:

1. The static method union creates a set thats the set-theoretic union of two existing sets (i.e., an element of the new sets array is set to true if that element is true in either or both of the existing setsotherwise, the new sets element is set to false).

2. The static method intersection creates a set which is the set-theoretic intersection of two existing sets (i.e., an element of the new sets array is set to false if that element is false in either or both of the existing setsotherwise, the new sets element is set to true).

3. Method insertElement inserts a new integer k into a set (by setting a[k] to true).

4. Method deleteElement deletes integer m (by setting a[m] to false).

5. Method toString returns a String containing a set as a list of numbers separated by spaces. Include only those elements that are present in the set. Use " --- " to represent an empty set.

6. Method isEqualTo determines whether two sets are equal.

Write a program to test class IntegerSet. Instantiate several IntegerSet objects. Test that all your methods work properly.

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

Step: 3

blur-text-image

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

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

Identify five strategies to prevent workplace bullying.

Answered: 1 week ago