CSC 232 - Introduction to Computer Science II
Lab 9
Write a program that stores in a priority queue twenty random integer values in the range 1 to 5. Then, use a method that you write to display the elements in the priority queue. The method must not destroy the contents of the priority queue. Then, use another method that you also write to output the number of occurrences of each value from 1 to 5 using the format n(count). For example, for the following 20 integers,
1 1 4 4 3 1 3 3 4 4 2 1 5 1 4 1 5 3 4 3
the formatted output should be
1(6) 2(1) 3(5) 4(6) 5(2)
Then, call the first method to display the contents of the priority queue another time.
A sample output from your program for the above twenty numbers should look as follows
1 1 1 1 1 1 2 3 3 3 3 3 4 4 4 4 4 4 5 5
1(6) 2(1) 3(5) 4(6) 5(2)
1 1 1 1 1 1 2 3 3 3 3 3 4 4 4 4 4 4 5 5
When you are done, demonstrate your program to the instructor, hand-in a hard copy of the source code and upload your solution in your CSC232 upload folder in a folder called LABS\lab9.