• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Input continuously collecting

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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



 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Heather Carey
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unlikely to be JAVAscripting. More likely JavaScript. A completely different language
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic