which I am having trouble with

Keep the program running (looping)

Posted 11 April 2007 - 04:26 AM

I have constructed one of my first (novice) calculator programs, and I am not real schooled up on getting this to repeat over (rather than have the prgram end and then have to restart it every time to perform another calculation.

Please help as I don't know how to do this yet!

At the moment, my code will compile but it goes straight to the "Press any key to continue" prompt.

Replies To: Keep the program running (looping)

Re: Keep the program running (looping)

Posted 11 April 2007 - 04:43 AM

I'm thinking an easier way to do this would be to replace that for loop with another while loop. create a boolean called "done" or "quit" or something like that and set it to false. Then: "while(!done) { ...", and set done to true when the user doesn't want to continue.

Re: Keep the program running (looping)

Posted 11 April 2007 - 06:32 AM

Instead of using yesOrNo == "n", try yesOrNo.equalsIgnoreCase("n");

Edit: Here is a page explaining the difference between the == operator and the equals method: http://www-128.ibm.c...j-ebb0917a.html
The equalsIgnoreCase String method is basically the same thing as the equals method with one obvious difference.