SlideShare a Scribd company logo
why will it not display all of the entries??
output
/nMenu
n.Add Entry
d. Delete Entry
u. Update Entry
l. Search
a. View All
q. Exit
/nMenu
n.Add Entry
d. Delete Entry
u. Update Entry
l. Search
a. View All
q. Exit
n
Enter a name: carnea
Enter an address: 30 carrollton
New Contact has been added,
/nMenu
n.Add Entry
d. Delete Entry
u. Update Entry
l. Search
a. View All
q. Exit
n
Enter a name: Tesia
Enter an address: 1010 hancover
New Contact has been added,
/nMenu
n.Add Entry
d. Delete Entry
u. Update Entry
l. Search
a. View All
q. Exit
n.Add Entry
d. Delete Entry
u. Update Entry
l. Search
a. View All
q. Exit
a
All entries:
carnea:30 carrollton
THE CODE:
import java.util.Scanner;
public class AddressBook {
public static void main(String[] args) {
Tablea addressBook = new Tablea();
Scanner scanner = new Scanner(System.in);
String name, address;
String action = null;
boolean moreEntries = true;
while (moreEntries) {
System.out.println("/nMenu");
System.out.println("n.Add Entry");
System.out.println("d. Delete Entry");
System.out.println("u. Update Entry");
System.out.println("l. Search");
System.out.println("a. View All");
System.out.println("q. Exit");
action = scanner.nextLine();
// Insert a new entry into the address book
switch (action) {
case "n":
System.out.print("Enter a name: ");
name = scanner.nextLine();
System.out.print("Enter an address: ");
address = scanner.nextLine();
addressBook.insert(name, address);
System.out.println("New Contact has been added,");
break;
// Delete an entry from the address book
case "d":
System.out.println("Enter a name to delete: ");
name = scanner.nextLine();
boolean deleted = addressBook.delete(name);
if (deleted) {
System.out.println("Address deleted");
} else {
System.out.println("Name not found");
}
break;
// Update an entry in the address book
case "u":
System.out.print("Enter a name to update: ");
name = scanner.nextLine();
System.out.print("Enter a new address: ");
address = scanner.nextLine();
boolean updated = addressBook.update(name, address);
if (updated) {
System.out.println("Address updated");
} else {
System.out.println("Name not found");
}
break;
// Lookup an entry in the address book
case "l":
System.out.print("Enter a name to look up: ");
name = scanner.nextLine();
String result = addressBook.lookUp(name);
if (result != null) {
System.out.println("Address: " + result);
} else {
System.out.println("Name not found");
}
break;
// Display all entries in the address book
case "a":
System.out.println("All entries:");
addressBook.displayAll();
break;
// Quit the program
case"q":
System.out.println("Quitting...");
}
}
}
}
public class Node {
private String name;
private String address;
private Node next;
public Node(String name, String address) {
this.name = name;
this.address = address;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return this.address;
}
public void setAddress(String address) {
this.address = address;
}
public Node getNext() {
return this.next;
}
public String toString() {
return "Name: "+ name +", Address:" +address;
}
public void setNext(Node node) {
this.next = next;
}
public void setAddress (Object newValue) {
this.address = address;
}
public void setName(Object newValue) {
this.name = name;
}
}
CLASS TABLEA:
import java.util.Scanner;
public class Tablea {
private Node mark;
public Node getMark() {
return this.mark;
}
public void setMark(Node mark) {
this.mark = mark;
}
public boolean insert(String name, String address) {
Node newNode= new Node(name,address);
if (this.mark== null) {
this.mark = newNode;
}else {
newNode.setNext(this.mark.getNext());
this.mark.setNext(newNode);
}
return true;
}
public String lookUp(String name) {
Node current = this.mark;
while(current!=null) {
if (current.getName().equals(name)) {
return current.getAddress();
}
current = current.getNext();
}
return null;
}
public boolean delete(String name) {
Node current = this.mark;
Node prev = null;
while (current!= null) {
if (current.getName().equals(name)) {
if (prev == null) {
this.mark = current.getNext();
}else {
prev.setNext(current.getNext());
}
return true;
}
prev = current;
current = current.getNext();
}
return false;
}
public boolean update(String name, String newValue) {
Node current = this.mark;
while (current != null) {
if (current.getName().equals(name)) {
current.setAddress(newValue);
return true;
}
current = current.getNext();
}
return false;
}
public boolean markToStart() {
if (this.mark== null) {
return false;
}
this.mark = null;
return true;
}
public boolean advanceMark() {
if (this.mark== null) {
return false;
}
this.mark = this.mark.getNext();
return true;
}
public String keyAtMark() {
if (this.mark== null) {
return null;
}
return this.mark.getName();
}
public String valueAtMark() {
if (this.mark== null) {
return null;
}
return this.mark.getAddress();
}
public int displayAll() {
Node current = this.mark;
int count = 0;
while (current != null) {
System.out.println(current.getName()+":"+ current.getAddress());
current = current.getNext();
count++;
}
return count;
}
}
why will it not display all of the entries--  output -nMenu n-Add Entr.pdf

More Related Content

PDF
There is something wrong with my program-- (once I do a for view all t.pdf
PDF
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdf
PDF
How to fix this error- Exception in thread -main- q- Exit java-lang-.pdf
PDF
How do you update an address according to this code- Currently- I fig.pdf
PDF
How can I add multiple names and addresses- To the following code- Tab.pdf
PDF
Note             Given Code modified as required and required met.pdf
PDF
Help with the following code1. Rewrite to be contained in a vecto.pdf
PDF
TutorialII_Updated____niceupdateprogram.pdf
There is something wrong with my program-- (once I do a for view all t.pdf
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdf
How to fix this error- Exception in thread -main- q- Exit java-lang-.pdf
How do you update an address according to this code- Currently- I fig.pdf
How can I add multiple names and addresses- To the following code- Tab.pdf
Note             Given Code modified as required and required met.pdf
Help with the following code1. Rewrite to be contained in a vecto.pdf
TutorialII_Updated____niceupdateprogram.pdf

Similar to why will it not display all of the entries-- output -nMenu n-Add Entr.pdf (20)

PDF
So here is the code from the previous assignment that we need to ext.pdf
PDF
could you implement this function please, im having issues with it..pdf
PDF
Use the code below from the previous assignment that we need to exte.pdf
PDF
please help with java questionsJAVA CODEplease check my code and.pdf
PPTX
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
PPT
Data structures cs301 power point slides lecture 03
PPTX
Laziness, trampolines, monoids and other functional amenities: this is not yo...
PDF
Please teach me how to fix the errors and where should be modified. .pdf
PPT
Paradigmas de Linguagens de Programacao - Aula #4
PPT
computer notes - Data Structures - 3
PDF
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
PDF
import java.util.Random;defines the Stock class public class S.pdf
PDF
package singlylinkedlist; public class Node { public String valu.pdf
PDF
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
PDF
6 c control statements branching & jumping
PPTX
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
PDF
#includeiostream #includecstdio #includecstdlib using na.pdf
KEY
How to Start Test-Driven Development in Legacy Code
PDF
Что нам готовит грядущий C#7?
PDF
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
So here is the code from the previous assignment that we need to ext.pdf
could you implement this function please, im having issues with it..pdf
Use the code below from the previous assignment that we need to exte.pdf
please help with java questionsJAVA CODEplease check my code and.pdf
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Data structures cs301 power point slides lecture 03
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Please teach me how to fix the errors and where should be modified. .pdf
Paradigmas de Linguagens de Programacao - Aula #4
computer notes - Data Structures - 3
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
import java.util.Random;defines the Stock class public class S.pdf
package singlylinkedlist; public class Node { public String valu.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
6 c control statements branching & jumping
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
#includeiostream #includecstdio #includecstdlib using na.pdf
How to Start Test-Driven Development in Legacy Code
Что нам готовит грядущий C#7?
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf

More from abc2232 (20)

PDF
Write the definition of a function printArray- which has two parameter.pdf
PDF
Which of the following least reflects the purpose of a business rule i.pdf
PDF
The Coefficients Table of a model is given as follows- Which variable(.pdf
PDF
Suppose James is thinking about retiring one year earlier than he had.pdf
PDF
explain about the community Chula Vista- CA 1- Defined Community ( wh.pdf
PDF
QUESTION 121 POINT How many distinct ways are there to arrange 2 orang.pdf
PDF
Q1) Create a program that do the following- 1- implement a singly link.pdf
PDF
Prior to 2020- the number plates on Poland's vehicles had the format o.pdf
PDF
Murgis Grinit 3-ris sin2x.pdf
PDF
LbJ Eha rosporise tume is iess ifan 1 mineles x x.pdf
PDF
kibit 41 he table below shows the counts by gender and highest degree.pdf
PDF
0- A student has to take examination in three courses X-Y and Z- He ha.pdf
PDF
A blocking high is Group of answer choices a high pressure system and.pdf
PDF
8-10 Let Xt and Yt be independent standard (one-dimensional) Brownian.pdf
PDF
Consider the following information about the international economy of.pdf
PDF
A set associative cache consists of 128 blocks divided into 2 blocks-s.pdf
PDF
Draw an EER diagram according to the notations discussed in class to a.pdf
PDF
1-) Why did we have an unstained sample- a CD4-PE only sample- and a.pdf
PDF
Esquire Comic Book Company tuvo ingresos antes de impuestos de $ 1-400.pdf
PDF
! At the beginning of the 21st century there was a considerable growth.pdf
Write the definition of a function printArray- which has two parameter.pdf
Which of the following least reflects the purpose of a business rule i.pdf
The Coefficients Table of a model is given as follows- Which variable(.pdf
Suppose James is thinking about retiring one year earlier than he had.pdf
explain about the community Chula Vista- CA 1- Defined Community ( wh.pdf
QUESTION 121 POINT How many distinct ways are there to arrange 2 orang.pdf
Q1) Create a program that do the following- 1- implement a singly link.pdf
Prior to 2020- the number plates on Poland's vehicles had the format o.pdf
Murgis Grinit 3-ris sin2x.pdf
LbJ Eha rosporise tume is iess ifan 1 mineles x x.pdf
kibit 41 he table below shows the counts by gender and highest degree.pdf
0- A student has to take examination in three courses X-Y and Z- He ha.pdf
A blocking high is Group of answer choices a high pressure system and.pdf
8-10 Let Xt and Yt be independent standard (one-dimensional) Brownian.pdf
Consider the following information about the international economy of.pdf
A set associative cache consists of 128 blocks divided into 2 blocks-s.pdf
Draw an EER diagram according to the notations discussed in class to a.pdf
1-) Why did we have an unstained sample- a CD4-PE only sample- and a.pdf
Esquire Comic Book Company tuvo ingresos antes de impuestos de $ 1-400.pdf
! At the beginning of the 21st century there was a considerable growth.pdf

Recently uploaded (20)

PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Presentation on HIE in infants and its manifestations
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
master seminar digital applications in india
PPTX
Lesson notes of climatology university.
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Institutional Correction lecture only . . .
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
01-Introduction-to-Information-Management.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
STATICS OF THE RIGID BODIES Hibbelers.pdf
Anesthesia in Laparoscopic Surgery in India
Presentation on HIE in infants and its manifestations
GDM (1) (1).pptx small presentation for students
Final Presentation General Medicine 03-08-2024.pptx
master seminar digital applications in india
Lesson notes of climatology university.
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Institutional Correction lecture only . . .
Microbial diseases, their pathogenesis and prophylaxis
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Chinmaya Tiranga quiz Grand Finale.pdf
human mycosis Human fungal infections are called human mycosis..pptx
01-Introduction-to-Information-Management.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
O7-L3 Supply Chain Operations - ICLT Program
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape

why will it not display all of the entries-- output -nMenu n-Add Entr.pdf

  • 1. why will it not display all of the entries?? output /nMenu n.Add Entry d. Delete Entry u. Update Entry l. Search a. View All q. Exit /nMenu n.Add Entry d. Delete Entry u. Update Entry l. Search a. View All q. Exit n Enter a name: carnea Enter an address: 30 carrollton New Contact has been added, /nMenu n.Add Entry d. Delete Entry
  • 2. u. Update Entry l. Search a. View All q. Exit n Enter a name: Tesia Enter an address: 1010 hancover New Contact has been added, /nMenu n.Add Entry d. Delete Entry u. Update Entry l. Search a. View All q. Exit n.Add Entry d. Delete Entry u. Update Entry l. Search a. View All q. Exit a All entries:
  • 3. carnea:30 carrollton THE CODE: import java.util.Scanner; public class AddressBook { public static void main(String[] args) { Tablea addressBook = new Tablea(); Scanner scanner = new Scanner(System.in); String name, address; String action = null; boolean moreEntries = true; while (moreEntries) { System.out.println("/nMenu"); System.out.println("n.Add Entry"); System.out.println("d. Delete Entry"); System.out.println("u. Update Entry"); System.out.println("l. Search"); System.out.println("a. View All"); System.out.println("q. Exit"); action = scanner.nextLine(); // Insert a new entry into the address book switch (action) { case "n": System.out.print("Enter a name: "); name = scanner.nextLine(); System.out.print("Enter an address: "); address = scanner.nextLine(); addressBook.insert(name, address); System.out.println("New Contact has been added,"); break; // Delete an entry from the address book case "d":
  • 4. System.out.println("Enter a name to delete: "); name = scanner.nextLine(); boolean deleted = addressBook.delete(name); if (deleted) { System.out.println("Address deleted"); } else { System.out.println("Name not found"); } break; // Update an entry in the address book case "u": System.out.print("Enter a name to update: "); name = scanner.nextLine(); System.out.print("Enter a new address: "); address = scanner.nextLine(); boolean updated = addressBook.update(name, address); if (updated) { System.out.println("Address updated"); } else { System.out.println("Name not found"); } break; // Lookup an entry in the address book case "l": System.out.print("Enter a name to look up: "); name = scanner.nextLine(); String result = addressBook.lookUp(name); if (result != null) { System.out.println("Address: " + result); } else { System.out.println("Name not found"); } break;
  • 5. // Display all entries in the address book case "a": System.out.println("All entries:"); addressBook.displayAll(); break; // Quit the program case"q": System.out.println("Quitting..."); } } } } public class Node { private String name; private String address; private Node next; public Node(String name, String address) { this.name = name; this.address = address; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public String getAddress() { return this.address; } public void setAddress(String address) { this.address = address; }
  • 6. public Node getNext() { return this.next; } public String toString() { return "Name: "+ name +", Address:" +address; } public void setNext(Node node) { this.next = next; } public void setAddress (Object newValue) { this.address = address; } public void setName(Object newValue) { this.name = name; } } CLASS TABLEA: import java.util.Scanner; public class Tablea { private Node mark; public Node getMark() { return this.mark; } public void setMark(Node mark) { this.mark = mark; } public boolean insert(String name, String address) { Node newNode= new Node(name,address); if (this.mark== null) { this.mark = newNode; }else { newNode.setNext(this.mark.getNext()); this.mark.setNext(newNode); }
  • 7. return true; } public String lookUp(String name) { Node current = this.mark; while(current!=null) { if (current.getName().equals(name)) { return current.getAddress(); } current = current.getNext(); } return null; } public boolean delete(String name) { Node current = this.mark; Node prev = null; while (current!= null) { if (current.getName().equals(name)) { if (prev == null) { this.mark = current.getNext(); }else { prev.setNext(current.getNext()); } return true; } prev = current; current = current.getNext(); } return false; } public boolean update(String name, String newValue) { Node current = this.mark; while (current != null) { if (current.getName().equals(name)) { current.setAddress(newValue); return true; } current = current.getNext(); } return false; } public boolean markToStart() { if (this.mark== null) {
  • 8. return false; } this.mark = null; return true; } public boolean advanceMark() { if (this.mark== null) { return false; } this.mark = this.mark.getNext(); return true; } public String keyAtMark() { if (this.mark== null) { return null; } return this.mark.getName(); } public String valueAtMark() { if (this.mark== null) { return null; } return this.mark.getAddress(); } public int displayAll() { Node current = this.mark; int count = 0; while (current != null) { System.out.println(current.getName()+":"+ current.getAddress()); current = current.getNext(); count++; } return count; } }