• 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

Dr Java says cannot find symbol

 
Greenhorn
Posts: 1
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I'm really really new here and I usually use Eclipse when I code but I'm using Dr Java right now and I compiled it and it says "cannot find symbol" in a Boolean expression where there clearly is a symbol.. It's in the line with the second monkeyanswer. What does it mean?

I'm support to "Write a program that generates four random integers between -3 and 3 (inclusive at both ends) and stores them in four variables. Display the four numbers and their sum. If the sum is less than zero then display "Negative" else display "Not Negative."

Here's my code (I thought I was done) if anyone can help:

 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

I have added code tags for you, doesn't it look better?

From that it can clearly see that the if statement is out of scope (outside the constructor where the rest of the logic is) getting the compiling error you've seen.

Also the random number generation does not use the user's input at all because I don't see a "scan.getInt()" anyway.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

K. Tsang wrote:... the if statement is out of scope (outside the constructor where the rest of the logic is) ...


And those braces make it an instance initialiser.
reply
    Bookmark Topic Watch Topic
  • New Topic