I am just startin out with programming so bare with me. I wrote a simple program that allows a user to enter an amount of money and it will output an amount in change. I was wondering how I would incorporate a loop so that a user has the option of inputing a yes or no statement if they want to keep using the body of the program over and over again. Any suggestions?
Welcome to JavaRanch, anthony! As you're new around these parts and have asked a good beginner's type question, allow me to recommend the following list of resources that you might find useful to have around.
Also, when you start to make use of the standard Java libraries a bit more, you'll likely find the API documentation nice to reference to learn just what things can do and how they do it. [ March 02, 2004: Message edited by: Dirk Schreckmann ]
Not to nitpick , but the only difference between the do/while and the while/repeat loop is that the do/while is guaranteed to run the loop body at least one time before exiting:
The "do something else" is the only code that will run, and it will only run once in the above example. Since that's the only purpose for the do loop's existence, and you meet the criteria, I say give that poor do loop its shot at the limelight (it gets used so infrequently). You may want to consider defining your exit criteria according to a bunch of exit constants, that way you can have the program exit with information about why it's exiting:
sev [ March 03, 2004: Message edited by: sever oon ]