Introduction This project creates a custom linked list struc

 Introduction:     This project creates a custom linked list structure.      It serves as an exerise in working with linked lists and nodes.       Overview:     Suppose the names \"Bob\", \"Dan\", and \"Ben\", are added, the result is:                  -----     -----     -----     -----     -----        head -->|  B  |-->| Ben |-->| Bob |-->|  D  |-->| Dan |--                 -----     -----     -----     -----     -----   |                                                                ---                                                                 -                                                            If the names \"Deb\" and \"Sarah\" are added, it looks like this:                  -----     -----     -----     -----     -----     -----      -----     -----        head -->|  B  |-->| Ben |-->| Bob |-->|  D  |-->| Dan |-->| Deb |--> |  S  |-->|Sarah|--                 -----     -----     -----     -----     -----     -----      -----     -----   |                                                                                               ---                                                                                                -      If \"Deb\" and \"Sarah\" are deleted, the list should look like the first list again.   Details:     Create a Java class called Index (not generic) that stores names and implements the    structure shown above.       Note that the names are kept in sorted order.  Letter nodes are always uppercase.    Lowercase names will follow uppercase strings in normal sorted order.     You may *not* use Java\'s LinkedList class.  You should create your own nodes and    link them together as shown in the illustration.       Your class should support the following methods.       20 points    add - Adds a new string.  Adds the letter node if not already present.     20 points    remove - Removes a string.  If the string is the last one for a letter, the letter              node should also be removed.     20 points    removeLetter - Removes a letter and all strings for that letter.       20 points    find - Finds a string by traversing the nodes.     10 points       toString - Prints the list as shown below using the first list above as an example:         B          Ben          Bob        D          Dan           10 points    main - Demonstrates the methods of your Index class 

Solution

package Linkedlist;

import java.util.ArrayList;
import java.util.Scanner;

public class Linkedlist {

public static void main(String[] args) {
Scanner input = new Scanner (System.in);
String option = optionChoise(input);
String option1 = \"ADD\";
String option2 = \"REMOVE\";
String option3 = \"LIST\";
String option4 = \"SORT\";
ArrayList List = new ArrayList();

}//end of main method
public static String optionChoise(Scanner input){
String op1 = \"ADD\";
String op2 = \"REMOVE\";
String op3 = \"LIST\";
String op4 = \"SORT\";
System.out.println(\"Enter the operation (ADD, REMOVE, LIST, or SORT): \");
String op = input.nextLine();
if((op.compareToIgnoreCase(op1)) !=0 || (op.compareToIgnoreCase(op1)) != 0 || (op.compareToIgnoreCase(op1)) !=0
|| (op.compareToIgnoreCase(op1)) !=0 || (op.compareToIgnoreCase(op1)) !=0){
System.out.println(\"This is not a valid input: \");
op = input.nextLine();
}
return op;
}
public static ArrayList addList(ArrayList tList, Scanner input){
System.out.println(\"Enter Name \");
String nameFirst= input.nextLine();
Name name = new Name();
Name1.firstName = nameFirst;
  
}//end of addList method
}//end of class

 Introduction: This project creates a custom linked list structure. It serves as an exerise in working with linked lists and nodes. Overview: Suppose the names

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site