• 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

Loops

 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys why is this loopinggggggggggggggggggggg over and over when I run it??

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have the line that waits for input commented out, so it's doing exactly what it's been programmed to do. 8^)
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mean this line? choice = EasyIn.getInt(); If I uncomment this line..I get this error...

F:\VendingMachine.java:26: cannot resolve symbol
symbol : variable EasyIn
location: class VendingMachine
choice = EasyIn.getInt();
^
1 error

Tool completed with exit code 1
 
William A White
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like you want to use a static method from the EasyIn class, but that class is not available to your code. Do you have a .class file for EasyIn? You need to import it into your program if you do.
 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is EasyIn ?
It's hard to help when you use methods or classes that we don't have.

When you comment out your line. Choice is always 0. So your while loop will never = 5.
[ May 02, 2005: Message edited by: Hentay Duke ]
 
author
Posts: 23956
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rose Evans:
You mean this line? choice = EasyIn.getInt(); If I uncomment this line..I get this error...

F:\VendingMachine.java:26: cannot resolve symbol
symbol : variable EasyIn
location: class VendingMachine
choice = EasyIn.getInt();
^
1 error



That is because you never declared the variable anywhere... Can't really help you as we can't tell what this variable is supposed to be anyway. But as a guess, it could be a class that reads from the console and returns an int.

As as side note, this question is similar to the way I put together christmas presents. Can't figure out a part, so I just don't use it... and later wonder why the toy isn't working properly...

Henry
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ha ha..thanks guys...with all of you giving me hints...I figured it out...THANKS A MILLION!!!
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For future reference, I have some ideas for what you can do to figure these things out yourself. When I encounter similar problems, I will add System.out.println() calls to print out the values of variables in my program. This allows me to see what the values are set to and compare it with what I think it should be. For example, if you add

at the beginning or end of the while loop in your original code, you would immediately have seen for yourself that it doesn't change. In my opinion, such "debugging output" is very helpful in tracking down problems.

Layne
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you everyone...for such great help and advice....It is greatly appreciated!!!
reply
    Bookmark Topic Watch Topic
  • New Topic