Here is my code. i have to creat a phone book in whcih you can add entries. find them. list all entries. and quit. the entries are to be put in an array as a class. Please tell me whats wrong with it and how i can search for a name and then pull the number and notes that go with that name and return it to the user. please and thank you! The code compiles fine but when i try to excecute the find option it errors. also i dont know how i would go about listing all the entries in the phone book. and im not even sure if they way i did the add an entry part works properly. it seems to when excecuting it in the program but i dont know if it actually stores it in the array or not.
import java.io.IOException; import java.util.*; public class phonebook { public static void main(String [] args) throws IOException{ int counter = 0; String name, number, notes; char firstcommand; System.out.print("Codes or names are entered with 1 to 8 characters. Use e to make a new entry, f to find an entry, l to list all current entries, and q to quit."); Scanner input = new Scanner(System.in); System.out.print("Please chose an option: "); firstcommand = (char)System.in.read(); while (firstcommand != 'q'){ System.out.print("Please chose an option: "); firstcommand = (char)System.in.read(); if (firstcommand == 'e') { System.out.print("Enter the code or name: "); name = input.next(); System.out.print("Enter number: "); number =input.next(); System.out.print("Enter any notes or press space then enter to leave blank: "); notes = input.next(); while (counter <100){ Entry entryList = new Entry(); if (counter >= 100) { System.out.print("phonebook is full"); break; } entryList.name = name; entryList.notes = notes; entryList.number = number; counter ++; } } else if (firstcommand == 'f') { String find; int index; System.out.print("Please enter the name or code you wish to find"); find = input.next(); index = Arrays.binarySearch( Entry.entryList, find); System.out.print(index); } } } } //here is my sperate class called Entry public class Entry { public static Entry[] entryList = new Entry[100]; public String name; public String number; public String notes; }