This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes Loop Structures Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Java in General
Bookmark "Loop Structures" Watch "Loop Structures" New topic

Loop Structures

Michael Steen

Joined: Feb 13, 2002
Posts: 4
I am very new to Java so please bare with me. I am writing a program that calculates court fines. At the end of the application I need to insert some code that will ask the user if they would like to continue at this point I need to invoke a loop if the answer is y finish if the answer is n. I have tried the while(!done) method I have tried IF ELSE (I have tried a lot of stuff). The variable I am using for the users answer of yes or no is String repeat; my boolean variable is boolean done = flase; From what I can tell the Boolean done = false is staying false for either choice. How can I get the repeat variable to yes or no to change the boolean done to true? I am taking on line classes and my instructor answer was to check s I could use anyones help at this point.
Thank you in advance for your assistance.
Les Dsouza

Joined: Jan 29, 2002
Posts: 27
If you are reading the user input from then the problem maybe because returns the user entered text+Carriage return + linefeed (in windows, in unix it will have text+ CR). Hence you need to discard these before using the input string for comparison.
check out the example below:

hope this helps...
Michael Steen

Joined: Feb 13, 2002
Posts: 4
Thank you for the input.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Loop Structures
It's not a secret anymore!