• Post Reply Bookmark Topic Watch Topic
  • New Topic

Newton's square root algorithm  RSS feed

 
Andrew Hocker
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For some reason this program spits out a bunch of errors in the DOS window, but none in my ide. Any noticeable problems with my code?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do the error messages say? Copying the first error message into your post will help a lot in understanding what's going on though. As a guess though, I'm thinking that BreezySwing classes haven't been included in your CLASSPATH - not from the DOS window anyway. You probably need to study how to set the CLASSPATH on your system to include the directory or jar file containing the BreezySwing directory.
 
Andrew Hocker
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Eddie Vanda
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,
Not sure if this is all that useful to you, but here goes.
Running your code is causing an exception which is not handled by the classes you are using (presumably from the ide). If you cannot change ide here are some suggestions:
Find a W2000 or XP PC which has a scrollable window, so you can see where the problem starts. The way with these dumps is that the clues are sometimes in the parts that have scrolled away but which you could look at in those other OS's.
You could enclose the code for each of your methods in try/catch clauses. Generally you start with a method with a "try {" and just before the exit or return statement use:

Using the generic Exception in this context is often frowned upon but if it handles your exception and stops the screen dump you have at least something to work with.
If you are still getting overflowing DOS screens then you might have to write your error messages to a file.
[ March 03, 2004: Message edited by: Eddie Vanda ]
 
Andrew Hocker
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Beginning to wonder if this is a breezyswing/swing problem, same stuff happens on a totally different program. Don't have the newton program on this computer, but what about this one, it gives me a shitload of errors too:

The messagebox tells me "some message about our method java.lang.ArithmeticException: / by zero". Any ideas?
[ March 04, 2004: Message edited by: Andrew Hocker ]
 
Eddie Vanda
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

<hr></blockquote>
There could be a problem in isDivisor if your divisor is 0. The % modulo operator would do a divide and return the remainder. This rewrite will return true if divisor is zero (dunno if that is what you really want) but otherwise should operate like your own code. If the figures provide any other exception (eg some kind of overflow or whatever) the values are printed along with the exception, but your program should not crash.

I haven't compiled this so there could be some errors in this.
[ March 05, 2004: Message edited by: Eddie Vanda ]
 
Andrew Hocker
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The whole problem arose from the division by 0. Thanks for helping me realize my blunder.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!