• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
NEVERMIND, I just figured out the answer to my question. Amazing how a cup of coffee will jolt the mind into powerdrive! :
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Hey! You're stepping on my hand! Help me tiny ad!
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic