View Single Post
  #7 (permalink)  
Old 01-03-2008, 12:45 AM
gibsonrocker800's Avatar
gibsonrocker800 gibsonrocker800 is offline
Senior Member
 
Join Date: Nov 2007
Location: New York
Posts: 143
gibsonrocker800 is on a distinguished road
Send a message via AIM to gibsonrocker800
ah, i'll be sure to check out Vectors (i'm learning alot today =]).

pringle: first of all, if you're having trouble with the menu of the program, you could use a switch statement for the choices. so:

Scanner in = new Scanner(System.in);
System.out.print("1: Initialise contact detail list 2: Display contact details list 3: Insert new entry into contact detail list 4: Delete entry from contact detail list 5: Search contact detail list");

int choice = in.nextInt();
switch(choice)
{
case 1: {code for option 1 and the line: break;}
case 2: {code for option 2 and the line: break;}
etc.
}

___________________________________________

You may have already known how to do this. But there it is, either way.

So now, the arrays should be written in the beginning of the programming so that it is within the scope of each case in the switch statement. (AKA, within the range).

As for your second question, it has that option so that the user can see all of the contact details. So, within case 1, you will have it print out all of the details using a for each loop. (or you could use a for loop, but for each is more efficient when dealing with all of the elements in an array). so:

-----------------------------
for(String str: arrayName)
{
System.out.println(str);
}
--------------------------

In this code, i am assuming that the arrays are arrays of Strings (because you said these arrays hold the information on the person).


So yeah, i hope this helps you out. If anything is unclear, just ask, i'll be here =]
Reply With Quote