This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Input continuously collecting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Input continuously collecting" Watch "Input continuously collecting" New topic
Author

Input continuously collecting

Heather Carey
Greenhorn

Joined: Nov 26, 2011
Posts: 15
This programs problem is that it will not allow more than one input and then it goes into no where land. If I do type a zero initially it takes me to the output statements. I'm to demonstrate the use of a method, that is why I'm averaging out my amount below and returning them to main.

I can't figure out why it won't continuously ask me to input a number until I input zero. Does the problem have something to do with my average method?

Thanks,
Heather



Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3169
    
  10
In your while loop you never change the value of data so the loop will never exit. (In the case of zero it never enters the loop) You need to move your prompt and calculation inside the loop and probably make it a do while loop


Joanne
Heather Carey
Greenhorn

Joined: Nov 26, 2011
Posts: 15
Thanks! I found a guy a work who knew JAVA scripting (I'm not sure what the difference is) and he said the exact same thing as you did about doing a DO WHILE loop. I'm so glad that you responded though because of all the notes I took from him that was one I forgot to write down.

Thanks!
Heather
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36592
    
  16
Unlikely to be JAVAscripting. More likely JavaScript. A completely different language
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Input continuously collecting
 
Similar Threads
A question about Scanner
Please help a newby out!
Counting in Array List/ Standard deviation
confirm dialog not
How to get a method to call a method