• 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

Whats wrong with this code :(

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ April 05, 2004: Message edited by: Dirk Schreckmann ]
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy.
The inequailty operator in java is != not <>
memory = memory - 1024;
d = d + 1;
for example could be written as:
memory -= 1024;
d++;
but that's a matter of personal taste I guess.
The TerminalIO package is from a book perhaps so I can't comment on that.
Use ubb code tags around your code in future as it makes it easier for ranchers to read.
 
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Peter,
When posting code sample(s), it is best if you place them inside UBB [code] tags. This will retain your code�s indentation and formatting when it is displayed (at least in most web browsers). It will also cause most web browsers to use a monospaced font when displaying it. All of this makes reading the code much easier. Some folks won't even try to read your code if it is not in [code] [/code] tags.
Take a look at the information on the Using UBB Tags page for more information. But ultimately, it is as simple as placing your code between a set of [code] and [/code] tags.
So if in the posting window you type:
[code]
public class SomeClass
{
    more code typed here
}
[/code]
It will be displayed as:

Regards, and welcome to the ranch.
 
Peter Shipway
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the tip and the info about UBB codes, I changed the <> operater to != and It still dosent work, Its like its an never-ending loop, my machine usally crashes... Oh and I have terminalIO package set-up correclty on my computer, tested other programs...
[ April 05, 2004: Message edited by: Peter Shipway ]
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just make a simple test with pencil and paper:
let memory become 64
memory > 1024 --> no
...
memory > 64 --> no
Therefore, memory stays 64, and it loops forever. Try
memory >= 64
and see, what happens. ;-)
BTW, what if I enter something like 64 + 1? Or is this considered as invalid input?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic