• Post Reply Bookmark Topic Watch Topic
  • New Topic

User Input until correct  RSS feed

 
Joseppi Juanlopez
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this code that's meant to keep prompting the user until the correct input is put in, between 1 and 9, which I know is generally a simple process, however it throws a question mark afterward instead of the prompt when I do this and I don't understand what's causing this. There's not a single question mark anywhere in the code.


 
Andrea Binello
Ranch Hand
Posts: 62
5
Eclipse IDE Java Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does TextIO.getInt() do? That TextIO is not a standard class, it's not in the JavaSE framework and perhaps belongs to some custom library (provided to you by someone?). I should do a Google search to see if it's mentioned somewhere ....

The question mark you have cited may be caused by that class.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A common problem, I am afraid. I think you need a utility class, which you can keep for ever. You can create a method which uses a Scanner object to return an XYZ:-Rob Spoor taught me how to do that. That code is of course incomplete. Now create another method which tests whether that XYZ returned is within a particular range:-More incomplete code, but similar to what you posted.
I believe TextIO is a class downloaded from the Stanford University website. It is in fact the sort of utility class I am advocating. If you search my posts for utility class and Scanner, you will probably find enough information to create your own version of TextIO. Most of my posts won't come up on that search, so you won't have to read all 50000 of them
 
Knute Snortum
Sheriff
Posts: 4276
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If TextIO is this:

http://math.hws.edu/javanotes/source/chapter4/TextIO.java

...then I believe the question mark come from TextIO itself.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!