aspose file tools*
The moose likes Beginning Java and the fly likes Help me solve the Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help me solve the "ANSWER" problem" Watch "Help me solve the "ANSWER" problem" New topic
Author

Help me solve the "ANSWER" problem

apollo abel
Ranch Hand

Joined: Mar 31, 2006
Posts: 32
Hello, im new here, and im a new java student.
i've written a program. however, the program asks the user a question, the user needs to answer either 1 or 2. i need the program to ask the question as long as the user doesnt enter 1 or 2. so if the user enters "2365" or "addasda" it will ask the question again.
this is the main class:


This is the test class:
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by apollo abel:
...i need the program to ask the question as long as the user doesnt enter 1 or 2. so if the user enters "2365" or "addasda" it will ask the question again...

Welcome to JavaRanch!

The key is the last line (commented out) in your first piece of code...

//while(!goodInput());

You just need to fill in what you want to do while the user keeps entering bad input...

[ March 31, 2006: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
apollo abel
Ranch Hand

Joined: Mar 31, 2006
Posts: 32
hmmm i'd like to try it. however, i found a way around it.
here is the code:
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by apollo abel:
hmmm i'd like to try it...

Hmmm... I think you should try it -- at least to demonstrate to yourself how it works.
 
 
subject: Help me solve the "ANSWER" problem