Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Whats wrong with this code :(

 
Peter Shipway
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • 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 ]
 
Carlos Failde
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • 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.
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • 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
  • 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 ]
 
Tobias Hess
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic