Assignment Detail


Implement a java program that uses a linkedlist

    Assignment Instructions

    Assignment ID: FG133135251

    COIT20256 Data Structures and Algorithms – Central Queensland University

    Lab Exercises

    Question 1. As part of Activity One you have written the contents in the resulting LinkedList – myList, after each step of execution if the following program code is executed. Test your answer by implementing the program. (submit your code).

    LinkedList<String> myList = new LinkedList<>(); ListIterator<String> iter; myList.addFirst(“John”); myList.addFirst(“David”);
    iter = myList.listIterator();; iter.add(“Peter”);; iter.add(“Joshua”);

    Question 2. Create a PriorityQueue of type Integer named eventMonths and add the following values:
    2, 5, 8, 3, 11, 7,and 6.
    Display the values using the peek method. (Check your answer from your Activity Two. Submit your code)
    Remove 2 from the queue and add 12. Remove 3 and add 4 to the queue.
    Display the queue.

    Question 3. Implement your Activity three and submit your source code.

    Question 4. (Inserting Elements in a LinkedList in Sorted Order) Write a program that inserts 25 random integers from 0 to 100 in order into a LinkedList object. The program should sort the elements, then calculate the sum of the elements and the floating-point average of the elements.

    Question 5. (Copying and Reversing Linkedlists) Write a program that creates a LinkedList object of 10 characters, then creates a second LinkedList object containing a copy of the first list, but in reverse order.

    Question 6. Implement a Java program that uses a LinkedList to store Integer objects that have the following values from an array
    Integer[] arr = {-1, 17, 28, -39, 12, 6, -2,-10};
    Use an iterator to traverse the linkedlist and replace each negative value by the corresponding positive number and doubled. Print out the contents of the resulting list.

    Question 7. Write an application to implement the three Set operations: intersection, union, and difference. You should build three methods corresponding to the operations. In your main method, test these methods on two HashSets of Strings.

    Question 8. Use a HashMap to create a reusable class for choosing one of the13 predefined colours in class Color. The names of the color should be used as keys, and the predefined Color objects should be used as values. Place this class in a package that can be imported into any java program. Use your new class in an application that allows the user to select a color and draw a shape in that color.

    Question 9. Write a Java class named StudentEmail that has data members for the name and number of a student. The class should have a constructor and appropriate accessor and mutator methods. In addition, the toString method should include the output information with student name, student number and the corresponding e-mail address.

    You write a program that creates a GUI with two labelled text fields, each one for name and student number, a text area to display the information, and two buttons – ‘add’ and ‘delete’. After the user of program enters data using the text fields and presses the ‘add’ button a StudentEmail object is created and stored in a LinkedList, and the student name, number and e-mail are displayed in the text area. If the user wants to delete a student e-mail entry, user can enter the student name in the text field and press the ‘delete’ button. If the entered student name doesn’t match any name in the LinkedList, a dialog message box pops out to indicate this.

    Attachment:- Data Structures and Algorithms.rar

    Need fresh solution to this Assignment without plagiarism?? Get Quote Now

    Expert Answer

    Asked by: Anonymous
    Plagiarism Checked
    Answer Rating:

    Plagiarism free Answer files are strictly restricted for download to the student who originally posted this question.

    Related Assignments

    Our customer support team is here to answer your questions. You can send Assignments directly to support team.
    👋 Hi, how can I help?