I'm heading in the right direction, however it still isn't functioning the way it should.
Lets say I enter 202 (which is invalid) it does take me to the second GUI that informs the user that ID number isn't valid if they enter a number that IS valid the information isn't displayed it pops right back into the first GUI "enter an id number"
I have tried to move the while around. I've tried to add to the error GUI. They don't show you this stuff in the book. So I'm pretty much stumped.
Here is my code I'm sure it will prove helpful
Code:import javax.swing.*; public class SearchList { public static void main(String[] args) { String[] directory = new String[5]; String[] idNum = {"101", "107", "109", "112", "217"}; String[] name = {"B. B.", "B. H.", "S. H.", "B. K.", "J. J."}; String[] phoneNum = {"601-555-5555", "478-777-7777", "561-999-9999","912-555-0000", "202-777-1111"}; String id; int x; int arrayIndex = 0; boolean deptIdFound = false; while(!deptIdFound) { id = JOptionPane.showInputDialog(null, "Enter an Id Number"); char aChar = id.charAt(0); for(x=0; x<idNum.length; ++x) { if(id.equals(idNum[x])) { deptIdFound = true; arrayIndex = x; } } if(deptIdFound) { JOptionPane.showMessageDialog(null, "Id Number is " + idNum[arrayIndex] + "\nName is " + name[arrayIndex] + "\nPhone Number is " + phoneNum[arrayIndex]); } else { id = JOptionPane.showInputDialog(null, id + " was not found in the list, please enter correct Id Number"); } } System.exit(0); } }
Anyone know my issue here?? I've tried everything


Reply With Quote


Bookmarks