Question: Linked List: Fruit Java 1. You are to create a class Fruit that has the following variables: Fruit next Fruit previous String name 2. You
Linked List: Fruit Java
1. You are to create a class Fruit that has the following variables:
Fruit next
Fruit previous
String name
2. You are to write a program (name it LinkedListFruitDemo.jav) in which you will:
Create a doubly linked list of Fruits with the following values stored in the variable space name of each node (note that Apple will be the first element in the linked List and Mango the last). Hint: using an array holding the names and a for loop would make this easier.
Apple Banana Cantaloupe Date Elderberry Fig Grape Honeyberry Ice Cream Bean Jostaberry Kiwi Lime Mango
Develop methods that will:
Iterate through (from front to back) the linked list elements printing the values stored in name.
Iterate through (from back to front) the linked list elements printing the values stored in name.
Ask the user for the name of a new fruit and add a new element (with that fruit stored as name) to the end of the linked list.
Ask the user to enter the name of a fruit and delete the element in the linked list that has the same name (if there is such an element)
Present to the user a menu that will allow them to select one of the options (methods) above.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
