Priority Queue Assignments

1. Write a program that will let you add names to a class that uses a priority queue, then print out the names in order. You should have a menu to let you add a name, peek at who is next or print and delete the name from the list and End.

2. Expand the class above to print out everyone in the list (the list should then be empty). Expand the list to include another print that would print everyone in the list without removing them (Hint - you may need a temporary local PriorityQueue to accomplish this).

3. Design a student class that will hold a first name, last name and an average. Write a a compareTo function with the class. The compareTo function should return true if its average is greater than the one being compared to it. Add 10 students into the priority queue and print out the students from lowest grade to highest.

4. Change your class so the PriorityQueue returns the student with the highest grade.

5. Given

public class Student
 {private String name;
  private double avg;
  private String gender;
  private int grade;  // year student is in school

  public void addOneGrade()
  // some constructors and methods

What would you have to add to be able to add this to a PriorityQueue (ordered by average)? Write any member functions needed.

6. Given a class that uses a PriorityQueue for the above Student class

private PriorityQueue<Student> pq;

Write a method that will return only the girls' names in an ArrayList (do not destroy the PriorityQueue)

public ArrayList<String> getGirlsNames()

7. We have a group of students in our PriorityQueue. We have just had graduation and want to remove all students in grade 12 from our PriorityQueue. When we leave the function all the students in grade 12 will be removed and all others will be passed on to the next grade.

public void removeSeniorsAndPromoteTheOthers()

8. We want to return a list of names in an array in sorted order. We have the names stored in an ArrayList. Write a method that will receive an ArrayList of Strings. Then add each name to a local PriorityQueue of Strings. Then remove names from PriorityQueue and put it into the array. Then return the array. Be sure and make any needed local declarations.

public String[] ReturnSortedNames(ArrayList ar)