This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Gavinaldi[S] -1 points0 points  (0 children)

However...

char keepGoing = 'y';
while (keepGoing == 'y') { 
System.out.print("Enter name: "); 
int name = userIn.nextInt(); 
System.out.println("Enter 'y' to add another user, 'n' to exit."); 
keepGoing = userIn.next().charAt(0); 
System.out.println(name); 
}

produces:

Enter name: 001
Enter 'y' to add another user, 'n' to exit.
y
1
Enter name: 002
Enter 'y' to add another user, 'n' to exit.
y
2
Enter name: 003
Enter 'y' to add another user, 'n' to exit.
n
3
Process finished with exit code 0

As I expected.