Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This assignment will use our person class. The application will create and manag

ID: 3826809 • Letter: T

Question

This assignment will use our person class. The application will create and manage a
linked list of person objects. In this application only the last name, first name,
and identification number will be used (we will use the zip code for the ID
number).
Your main() should display the following menu:
MENU
1. add a person to the list
2. delete a person from the list
3. change a persons information
4. locate a person by ID number
5. locate a person by last name
6. print the list on the screen
7. load the list from a file
8. save the list to a file
9. exit the program
Enter your selection:
You should write functions to implement the menu options. In some cases, you may
wish to implement the menu options within main(), such as file I/O. In the case of
menu item 3, the only information that would ordinarily be changed would be a
woman's last name if she were married or divorced, but the code should also allow
for a first name change as well, but not the ID number. The menu option 6 should
simply print the list in whatever order the list items are in.

Explanation / Answer

package Project_1;

public class Person
{
protected String Name; // name of the person earning this ID
protected int ID; // the ID value
protected int String loc;//location of person

/** Constructor to create a person entry */
public Person(String Name, int ID,string loc)
{
this.Name = Name;
this.ID = ID;
this.loc=location;
}

/** Retrieves the name field */
public String getName()
{
return name;
}

/** Retrieves the id field */
public int getid()
{
return id;
}
/** Retrieves the loc field */
public string getloc()
{
return id;

/** Returns a string representation of this entry */
public String toString()
{
return name + ", " + id +","+ loc" ";
}

}

-------//details//-----------

package Project_1;

import linkedList.*;

import java.util.*;


/** Class for storing id in an array in non-decreasing order. */
public class personlist
{

//add function
public SLinkedList<person> add(person firstname,Person Last name, SLinkedList<Person> id,SLinkedList<Person> loc)
{
Node<person> currentNode = ids.getFirst();
Node<person> nextNode = null;
Node<person> previousNode = null;
Node<person> newNode = new Node<person>();
newNode.setElement(Firstname,lastname);

if(id.getSize() == 0)
{
id.addFirst(newNode);
}
else
{
while(currentNode != null)
{   
nextNode = currentNode.getNext();
if(nextNode == null)
{
Id.addLast(newNode);
}
else
{
Id.addAfter(currentNode, newNode);
break;
}   
previousNode = currentNode;
currentNode = currentNode.getNext();
}
}
return id,loc;
}

//remove function
public void remove(int i)
{

}

//print function
/*person printing;
printing=node.Getelement; //pseudo code for making it work right
print(printing.getid)
print(print.getfirstname)
Print(Print.getlastname)
Print(Print.getloc)
*/
public void print(SLinkedList<person> id)
{
Node<person> currentNode = id.getFirst();
person currentEntry = currentNode.getElement();
System.out.printf("firstname,lastname,loc");
for(int i = 0; i < id.getSize(); i++)
{
System.out.printf("loc,name %s", currentEntry.toString());
currentNode = currentNode.getNext();
currentEntry = currentNode.getElement();
}
System.out.println("print list");
}
}
public class printlist {
/**
* @param args
*/

public static void main(String[] args)
{
SLinkedList<person> New_id = new SLinkedList<person>(); //Linked List for person
person entry;
Name_id = new_id();   
entry = new person("Flanders", 681,"roma");   
New_id = Name.add(entry, new_id,loc);
entry = new Person("Krusty", 324,"fore");
New_id = Name.add(entry, new_id,loc);
entry = new Person("Otto", 438,"losangel");
New_id = Name.add(entry, new_id,loc);
entry = new Person("Bart", 875,"london");
New_id = Name.add(entry, new_id,loc);
entry = new Person("Homer", 12,"verin");
New_id = Name.add(entry, new_id,loc);
entry = new Person("Lisa", 506,"varrey");
New_id = Name.add(entry, new_id,loc);
entry = new Person("Maggie", 980,"kelly");
New_id = Name.add(entry, new_id,loc);
entry = new Person("Apoo", 648,"brond");
New_id = Name.add(entry, new_id,loc);
entry = new Person("Smithers", 150,"west");
New_id = Name.add(entry, new_id,loc);
entry = new Person("Burns", 152,"northen");
New_id = Name.add(entry, new_id,loc);
System.out.println("The Original lastname,new_id,loc");
name.print(New_id,loc);
entry = new Person("eyan", 895,"mally");
New_id = Name.add(entry, new_id,loc);
System.out.println("after adding eyan");
name.print(new_id,loc);

//new_id = name.remove(4);
System.out.println("after removing "name of person");
name.print(new_id,loc);
}
}

-----To add specific node--
newNode->nextNode = startNode
startNode = newNode
index = 0
currentNode = startNode
while index is less than position
currentNode = currentNode.nextNode // move your node pointer to the position
increment index
newNode.nextNode = currentNode.nextNode // some more bound checking required
currentNode.nextNode = newNode

------To remove specific node--
index = 0
delNode = startNode
while index is less than (position - 1)
delNode = delNode.nextNode // move your node pointer to the position
increment index

delNode.nextNode = delNode.nextNode.nextNode
storeNode = delNode.nextNode // some more bound checking required
delNode.nextNode = delNode.nextNode.nextNode // some more bound checking required

------to Update-----
public void add(Node<person> list)
{
Node<person> currentNode = list.getFirst();
Node<person> prevNode = null;
if (newid.size() == 0 || listid.compareTo(currentNode) < 0)
{
newid.addFirst(list);
}
while (currentNode != null && currentNode.compareTo(list) > 0)
{
prevNode = currentNode;
currentNode = currentNode.getNext();
}
if (currentNode == null) {
newid.addLast(list);
} else
{
newid.addAfter(prevNode, list);
}
}
public void remove(Node<person> list) {

Node<person> currentNode = newid.getFirst();
Node<person> prevNode = null;
while (currentNode != null && !currentNode.equals(prienthe list))
{
prevNode = currentNode;
currentNode = currentNode.getNext();
}
if (currentNode == null) {
System.out.println("Node not found");
return;
}
if (prevNode.getNext().getNext() != null)
{
// if there is, we follow the logic from the pseudo code

prevNode.setNext(prev.getNext().getNext());
} else
{
newid.removeLast();
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote