IN JAVA Minimal Documentation Required (no javadoc) Purpose The purpose of this assignment is to introduce you to...

80.2K

Verified Solution

Question

Programming

IN JAVA

Minimal Documentation Required (no javadoc)

Purpose

The purpose of this assignment is to introduce you to basicoperations on a linked list.

Specifics

Design a program that generates a linked list of randomlygenerated Integer objects. Present a menu at program start thatgives the user the following options (most of these options willhave corresponding methods in a Linked List class):

1. Create a new list. The size will be specified by the user,make sure a non-negative value is entered. If there is apre-existing list when this option is chosen, make sure you deletethe contents of that list before creating your new list.

2. Sort the list. How you implement this is up to you. You caninsert items in the list such that the list is always in sortedorder or you can write a sort routine. You may not call a sortroutine provided by the Java API.

3. Print the list (to the screen), one number per line.

4. Print the list in reverse order (to the screen), one numberper line.

5. Generate a sub-list that contains all the even numbers in thecurrent list. This list should be returned and the contents shouldbe displayed (to the screen), one number per line.

6. Print the contents of every \"nth\" node in the list. Obtainthe \"n\" from the user, ensure it is greater than 0.

7. Delete node(s) containing an integer value entered by theuser. You should report how many were deleted to the user.

8. Delete the contents of the current list.

9. Quit

You may use any linked list implementation you wish (singlylinked, doubly linked, dummy head node, circular).

In addition to your LinkedList class, include a driver filecalled ListTester that will contain the menu and anything else youdeem necessary (perhaps a utility to generate randomIntegers...).

Keep things modular and encapsulate your data properly - do notlet anything outside the Linked List class have direct access toany of the nodes.

Do not accept Invalid input of any type from the user and do notlet user input crash your program.

PLEASE IMPLEMENT ALL

Answer & Explanation Solved by verified expert
4.2 Ratings (859 Votes)
Dear Student I have developed the code for all the requirements Created separate classes for the functionality and driver Please use any editor for testing the code Let me know if you find any difficulties in understanding I have provided adequate comments for your understanding I am pasting the code and output I have used java inbuilt linked list for the    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students