GIVEN THE FOLLOWING public class IntegerSet {boolean []set=new boolean[101]; pub
ID: 3528398 • Letter: G
Question
GIVEN THE FOLLOWING public class IntegerSet {boolean []set=new boolean[101]; public IntegerSet(int a[]) {int i; for(i=0;i<101;i++) {set[i]=false; } for(i=0;i<101;i++) set[a[i]]=true; } public IntegerSet() {int i; for(i=0;i<101;i++); set[i]=false; } public void setSet(int a[]) {int i; for(i=0;i<101;i++) {set[i]=false; } for(i=0;i<101;i++) set[a[i]]=true; } public boolean[] getSet() {return set; } } Please do the following modifications to the above JAVA code: Provide an InsertElement(int k) member method that inserts a new integer k into a set (by setting a[ k ] to true). If k is not within range (0 to 100) output an error message. Provide a DeleteElement(int k) member method that deletes integer k (by setting a[ k ] to false). If k is not within range (0 to 100) output an error message. Provide a member method named Print() that prints a set as a list of numbers separated by comma within curly braces. Print only those elements that are present in the set (i.e., their position in the array has a value of true). For example, the following could be an output of this method {2, 5, 18, 56, 100}. Output {} for an empty set. Provide a Union(IntegerSet y) member method that returns a third set that is the settheoretic union of two existing sets (i.e., an element of the third set's array is set to true if that element is true in either or both of the existing sets, and an element of the third set's array is set to false if that element is false in both of the existing sets). NOTE: Of the two existing sets one set exists within the object whose Union method is being called and the other set is given to the Union method as argument (y). The Union method returns the third set that it creates inside it to represent the union of the two existing sets.Explanation / Answer
please rate - thanks found and corrected a problem or 2 in original -- get back to me if any problems public class IntegerSet {boolean []set=new boolean[101]; public IntegerSet(int a[]) {int i; for(i=0;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.