File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Wanting to ask user to keep Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Wanting to ask user to keep "inputting" at the command prompt until a condition is reached" Watch "Wanting to ask user to keep "inputting" at the command prompt until a condition is reached" New topic
Author

Wanting to ask user to keep "inputting" at the command prompt until a condition is reached

Karen Haq
Greenhorn

Joined: Mar 17, 2010
Posts: 22
Hi, all

All I want to do is to ask the user to keep inputting a "1" for tossing the coin. The program should keep a running total of how many "heads" and "tails". When the the user enters "2" the program should output the running total for both heads and tails.

As it codes now, the user is prompted only one time because I wanted to test for bugs and for logic errors, keeping it simple.

Here is my test class:


And here is my source class:










Karen Haq
Greenhorn

Joined: Mar 17, 2010
Posts: 22
NEVERMIND, I just figured out the answer to my question. Amazing how a cup of coffee will jolt the mind into powerdrive! :
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11499
    
  16

I edited your post to have code tags. They preserve spacing and make code much easier to read. To use them yourself, you can click the button above where you type your post, the tags drop in, then paste your code between them.

Thanks, and welcome to the Ranch!


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Wanting to ask user to keep "inputting" at the command prompt until a condition is reached