Matt Gerrans
Posts: 1153
Nickname: matt
Registered: Feb, 2002
|
|
Re: basic search
|
Posted: Dec 11, 2002 12:37 PM
|
|
The problem is that it is falling through all the if statements. You can fix this by adding an else before the second if, but really in this case it would be better to use a switch. In fact, it would be even better to have a separate search method, that way the search can be generalized later, to perhaps look in a database or some other source.
By the way, it is generally not a good idea to compare floats or doubles to ints, unless you round or truncate (depending on your purposes) the floating-point number first. In this case, in particular, since you are using "part numbers" these would almost always be entirely digits (allowing you to read it in as an int, or BigInteger, if the are really long) or a mix of numbers and digits (in which case, you'd probably use a String).
|
|