2010-11-16 11:21:08 UTC
JOptionPane.showMessageDialog(null, list.displayPeopleWithSameAge(keybd));
*****
Basically, I need to make a workable loop that repeatedly ask the user to "Enter the age" while user does not enter -1. If it's not -1, then it should send the String keybd to second line and print.
But the way I'm coding now.. if user enters 11, then it prints 11, then repeats first line, user enters 22, then THE PROBLEM HERE IS THAT IT PRINTS 11 and 22, while it should only print 22..
Can this be done with few lines of for/while/if statements? THANKS!!!
So correct output should be something like:
First line - user enters 12
Second line - print 12
Repeats first line - user enters 40
Second line - print 40
Repeats first line - user enters -1
Program terminates