Tree Set / Hash Set Assignments
-
Write a function that will have the computer pick and return 25 unique random numbers between 1 and 100.
public static TreeSet get25()
Given in a class
private TreesSet t;
-
Write a method that will do the following
public TreeSet union (TreeSet b) // returns union of 2 sets
public TreeSet intersection (TreeSet b)
public TreeSet difference (TreeSet b) // in s not in b
- Write a method that will let the computer pick 25 non-repeating random numbers between 1 and 100 and will then pick 25 more unique random numbers between 1 and 100 and will tell what percentage of the time there will be at least 1 number in common. Run the simulation 10,000 times to get the percentage.
boolean oneInCommon() // use method from #1
-
Write a function that will pick random numbers between 1 and 100 until all 100 numbers are picked. What is the average for the amount of numbers that had to be selected in order to get all 100 numbers. Run the simulation 10,000 times to get the average.
int howManyTimes()
-
Write a student class that has a first name, last name and a list of college choices (HashSet of Integer between 1 and 100). Then write a school class that will store a Linked List of Students.
-
One method should be to print out all the students interested in a particular college, given its coded number.
public void printStudents(int n)
- One of the member methods of the school class should be a busTrip method that prints each college ID number followed by the students who are interested in attending that college.
public void busTrip()
-
Write a function that will print the college that is the most popular with the students. You may assume that there is only one college chosen the most.
public void printMostPopularCollege()
-
Write a function that will print out the colleges that no student picked.
public void printCollege()
-
Write a House class that store a street, city and a Treeset of Strings that are features the house has. Then write a Houses class that has an ArrayList of House. One of the methods of the Houses class should be :
void printHouses(String features[], double price)
which will print all houses that have all the features in the array of features that is passed to it and are less than or equal to the price.
-
Create a Tree Set of student names (a String with last name listed first - example Smith, James) and at the same time create a Hash Set of the same names. Iterate through and print out the names. Are the lists the same. How are they stored in the computer in each of the data structures.
-
Extend the Hash Set Class (HashSet2) so that it has a print() method. Test your new class to make sure it prints out the Objects.
-
Write a method that will print out 10 names in random order. The names are stored in a HashSet. Iterate a random distance over the set. Print the name. Then remove the name from the set.
-
Given that there is an ArrayList that contains Student Objects that has a
public String getName() and public int getAvg() methods. Write a method that will return the student who has the highest average. Since two, or more, students may be tied we are going to return the results as a Set.
private ArrayList<Student> ar;
public Set getHighStudents()
|