• Post Reply Bookmark Topic Watch Topic
  • New Topic

user input for 2nd time not working  RSS feed

 
ibrahim yener
Ranch Hand
Posts: 202
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there
I am currently learning java and i am trying to some program for educational purpose.

What i am trying to do is :

Get user entry and convert it to lowercase or uppercase and add into dynamic array.
So my program doesn't ask for user entry to decide continue or not for second time.

I appreciate for any help or idea.

 
Ashish Dutt
Ranch Hand
Posts: 172
Java MySQL Database Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there,
Its strange, your code works absolutely fine for me.

This is what i did
Test Run 1:
Enter Something
Press number or  "q" to quit
abc
You entered lowercase "a" letter and it's Case conversion is : A
M
You entered UPPERCASE "M" letter and it's Case conversion is : m
1
Either you entered number or pressed  "q"
BUILD SUCCESSFUL (total time: 26 seconds)

Test Run 2:
run:
Enter Something
Press number or  "q" to quit
P
You entered UPPERCASE "P" letter and it's Case conversion is : p
m
You entered lowercase "m" letter and it's Case conversion is : M
1
Either you entered number or pressed  "q"
BUILD SUCCESSFUL (total time: 31 seconds)

Test Run 3:
run:
Enter Something
Press number or  "q" to quit
1
Either you entered number or pressed  "q"
BUILD SUCCESSFUL (total time: 3 seconds)

 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ibrahim yener wrote:So my program doesn't ask for user entry to decide continue or not for second time.

If you mean it doesn't print
Enter Something
Press number or "q" to quit

the second time, that is because the code to print that text is outside your loop. Move lines 13 and 14 inside the loop and it will work.

Also, don't use System.exit to leave the loop. This will exit the whole program and won't print the strings. You have a condition controlling your while loop so just set that condition to false.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!