|
Post by Sylph on Nov 4, 2001 19:08:06 GMT -5
i think you have to check if the char equals '3', not "3".
|
|
Kamui
Junior Member
Posts: 6
|
Post by Kamui on Nov 4, 2001 20:06:47 GMT -5
Thanks Sky, Blues and Sylph ....i got the class to work. My problem was fixed when i used '3' instead of "3". ;D
|
|
|
Post by 1.8T on Nov 6, 2001 19:43:35 GMT -5
problem, when i make parameters, 1 , 1000 i noticed the the results begin with 31 and on. ., anyone know why?
also, i'm having trouble removing the values, with multiple threes in them, 33 appears twice, 333 appears 3 times, and then 330-340 range is repeated twice .,. etc... thx ... .
|
|
|
Post by Majin_Blues on Nov 6, 2001 20:40:41 GMT -5
i remember that problem...
if i remember correctly, you have to find a way so that it knows it printed it already...
say, some sort of marker... or what would be another way to stop checking numbers? (this is so simple, i missed it before)
i dunno why it starts at 31... maybe you have some 3 stuck at the beginning or it's your count... read it over carefully
|
|
|
Post by Brutal_Chicken on Nov 6, 2001 20:48:01 GMT -5
Please tell me I'm not the only one that started with the first parameter, converted it to a string, checked if it had a '3' in it somewhere adding to an index if needed, added 1 to first parameter then had it converted to a string, ad naseum till the second parameter is reached.
|
|
|
Post by Majin_Blues on Nov 6, 2001 20:53:54 GMT -5
as long as it works, right? ;D
i just used for loops - with defined parameters for the conditions... seemed easier to keep track of things that way
|
|
|
Post by bladehunter on Nov 6, 2001 21:48:18 GMT -5
I did it brutal's way and it's good.
Yields the correct output, that's all i care
|
|
|
Post by Brutal_Chicken on Nov 7, 2001 15:14:57 GMT -5
Here's a dilly of a pickle; I tried running my program at the CDF and all it printed out was any number with a three at the front ( ie. 3, 30, 31, 32..., 3000, etc). What I had to do just to get that was to remove the index for the if statement that checked if the number had a three in it. So now it consistently prints out nums with three at the front.
The error message while trying to run the program is "Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 1"
Anyone have a clue as to a possible cause for this?
|
|
|
Post by Majin_Blues on Nov 7, 2001 15:30:22 GMT -5
u might want to check your loop condition... make sure it's from 0 to like count < word.length(), not count <= word.length()..
as just for the first digit, you need to find a way so that it looks through ALL the digits of a number - i.e. it repeats until it's done looking through the number (hint... i wonder what to use?) unless it finds a 3, in which case you can stop
|
|
|
Post by Brutal_Chicken on Nov 7, 2001 21:08:54 GMT -5
Actually, what I think my real problem is the fact that I can't seem to use an index other than 0 or else that error appears.
Ok, so where did you guys declare your index in the overall picture? Right before the static method, inside the method itself, or in the "main" which doesn't make any sense. It's driving me nutso.
|
|
|
Post by bladehunter on Nov 7, 2001 21:11:51 GMT -5
I put it inside the method
Want me to specify where in the method?
|
|
|
Post by Brutal_Chicken on Nov 7, 2001 21:23:49 GMT -5
Well there's no sense in that unless there's a secret no one's telling me of static methods. If it's in the loop then you'll just keep resetting it to zero, so it has to be before whatever recursive loop you have.
|
|
gon
New Member
Posts: 4
|
Post by gon on Nov 8, 2001 19:34:01 GMT -5
I know how to find whether '3' in charAt(0)... but how about the length of the string is great than 1, so many concerns.. am I making it too complicate?!.. please help me!!
|
|
|
Post by bladehunter on Nov 8, 2001 19:57:21 GMT -5
Gon, try thinking of how u would check one String for a certain character. If u think of it that way, u might just get it.
|
|
gon
New Member
Posts: 4
|
Post by gon on Nov 8, 2001 20:21:27 GMT -5
int count = a; while (count <=b){ String num = Integer.toString(count); for (i=0 ; i <= num.length() ; i++ ){ ...... I am wrong ....right?!...
|
|