hello...this is my firt post...

i need your help in this one...im doing a palindrome program...

"application that reads in a five-digit integers and determines whether

or not it is a palindrome. if the number is not a five-digits long. displays

an error message dialog indicating the problem to the user.when

dismisses the error dialog, allow the user to enter new value. Using

GUI cotrols..."

thats it...thanks

[426 byte] By [kathleenkatea] at [2007-10-3 5:25:34]
# 1
Okay. You have our permission to get working on that.If you have been working on that and are stuck in a specific place then please post formatted code with what you have so far and ask a specific question about what problem you are having.
cotton.ma at 2007-7-14 23:32:46 > top of Java-index,Java Essentials,Java Programming...
# 2
And your problem is?
prometheuzza at 2007-7-14 23:32:46 > top of Java-index,Java Essentials,Java Programming...
# 3
> And your problem is?That was a question to the OP, of course...
prometheuzza at 2007-7-14 23:32:46 > top of Java-index,Java Essentials,Java Programming...
# 4
Hint:- use pencil and paper to find out what you want your program to do, step-wise- look at String and for loops or StringBufferAlso, look at the Swing tutorials. And probably your lecture notes.
CeciNEstPasUnProgrammeura at 2007-7-14 23:32:46 > top of Java-index,Java Essentials,Java Programming...
# 5
Different kido, same question!There must be a classroom present.Show us some work and we'll help you with specific issues,
manuel.leiriaa at 2007-7-14 23:32:46 > top of Java-index,Java Essentials,Java Programming...
# 6

You cna do the swing part on your own. I don't know any of that stuff.

import java.util.Scanner;

public class Caller

{

private static final int PALINDROME_LENGTH = 5;

public static void main(String args[])

{

Scanner in = new Scanner( System.in );

String userInput = "";

do

{

System.out.print( "Enter your palindrome of length "

+ PALINDROME_LENGTH + ": " );

userInput = in.nextLine();

if ( userInput.length() == PALINDROME_LENGTH )

{

if ( isPalindrome( userInput ) )

{

System.out.println( "Your number " + userInput

+ " is a palindrome" );

}

else

{

System.out.println( "Your number " + userInput

+ " is NOT a palindrome" );

}

}

else

{

System.out.println( "Invalid length" );

}

}

while ( !userInput.equalsIgnoreCase( "exit" ) );

}

private static boolean isPalindrome(String s)

{

int halfLength = (PALINDROME_LENGTH - 1) / 2;

char[] chars = s.toCharArray();

for ( int i = 0; i < halfLength; i++ )

{

if ( !(chars[i] == chars[PALINDROME_LENGTH - 1 - i]) )

{

return false;

}

}

return true;

}

}

Norweeda at 2007-7-14 23:32:46 > top of Java-index,Java Essentials,Java Programming...
# 7
There he goes again...
CaptainMorgan08a at 2007-7-14 23:32:46 > top of Java-index,Java Essentials,Java Programming...
# 8
He's a true buddy;)
manuel.leiriaa at 2007-7-14 23:32:46 > top of Java-index,Java Essentials,Java Programming...
# 9
> You cna do the swing part on your own. I don't know> any of that stuff.Do you think you are helping?
kajbja at 2007-7-14 23:32:46 > top of Java-index,Java Essentials,Java Programming...
# 10

I must also add that the previous code only works for odd length plaindromes.

Use this method and it'll work for even and odd ones. Sorry I forgot about that...silly me.

private static boolean isPalindrome(String s)

{

int halfLength = 0;

if ( PALINDROME_LENGTH % 2 == 1 )

{

halfLength = (PALINDROME_LENGTH - 1) / 2;

}

else

{

halfLength = PALINDROME_LENGTH / 2;

}

char[] chars = s.toCharArray();

for ( int i = 0; i < halfLength; i++ )

{

if ( !(chars[i] == chars[PALINDROME_LENGTH - 1 - i]) )

{

return false;

}

}

return true;

}

Norweeda at 2007-7-14 23:32:46 > top of Java-index,Java Essentials,Java Programming...
# 11
> > You cna do the swing part on your own. I don't> know> > any of that stuff.> > Do you think you are helping?No, he's a big-time grudge holder and thinks he's ticking me off.
warnerjaa at 2007-7-14 23:32:46 > top of Java-index,Java Essentials,Java Programming...
# 12
> He's a true buddy> ;)That's a foe in disguise.
aniseeda at 2007-7-14 23:32:46 > top of Java-index,Java Essentials,Java Programming...
# 13
> > Do you think you are helping?I sure do. Hey, I don't know swing at all. She still has to do that part.
Norweeda at 2007-7-14 23:32:46 > top of Java-index,Java Essentials,Java Programming...
# 14

> > > You cna do the swing part on your own. I don't

> > know

> > > any of that stuff.

> >

> > Do you think you are helping?

>

> No, he's a big-time grudge holder and thinks he's

> ticking me off.

Now, *this* is amusing. :o)

aniseeda at 2007-7-14 23:32:46 > top of Java-index,Java Essentials,Java Programming...
# 15
> > > > Do you think you are helping?> > I sure do. Well you arent.
CaptainMorgan08a at 2007-7-21 11:03:01 > top of Java-index,Java Essentials,Java Programming...
# 16

> I must also add that the previous code only works for

> odd length plaindromes.

>

> Use this method and it'll work for even and odd ones.

> Sorry I forgot about that...silly me.

Why not change it to..

public static boolean isPalindrome(String text) {

return text.equals(new StringBuilder(text).reverse().toString());

}

Kaj

kajbja at 2007-7-21 11:03:01 > top of Java-index,Java Essentials,Java Programming...
# 17
> I must also add that the previous code only works for> odd length plaindromes.> > Use this method and it'll work for even and odd ones.> Sorry I forgot about that...silly me.Yes, silly you.
prometheuzza at 2007-7-21 11:03:01 > top of Java-index,Java Essentials,Java Programming...
# 18

> >

> > Do you think you are helping?

>

> I sure do. Hey, I don't know swing at all. She

> still has to do that part.

How much do you think the OP is learning if he doesn't give it a try on his own? The only thing that he will learn if you write the code for him is copy & paste.

Kaj

kajbja at 2007-7-21 11:03:01 > top of Java-index,Java Essentials,Java Programming...
# 19

> > I must also add that the previous code only works

> for

> > odd length plaindromes.

> >

> > Use this method and it'll work for even and odd

> ones.

> > Sorry I forgot about that...silly me.

>

> Why not change it to..

> > public static boolean isPalindrome(String text) {

> return text.equals(new

> ew StringBuilder(text).reverse().toString());

> }

>

>

> Kaj

There's more than one way to skin a cat.

Norweeda at 2007-7-21 11:03:01 > top of Java-index,Java Essentials,Java Programming...
# 20

> > >

> > > Do you think you are helping?

> >

> > I sure do. Hey, I don't know swing at all. She

> > still has to do that part.

>

> How much do you think the OP is learning if he

> doesn't give it a try on his own? The only thing that

> he will learn if you write the code for him is copy &

> paste.

>

> Kaj

I don't care what they learn. That's up to them. I'm not the learning police.

Norweeda at 2007-7-21 11:03:01 > top of Java-index,Java Essentials,Java Programming...
# 21

> > >

> > > Do you think you are helping?

> >

> > I sure do. Hey, I don't know swing at all. She

> > still has to do that part.

>

> How much do you think the OP is learning if he

> doesn't give it a try on his own? The only thing that

> he will learn if you write the code for him is copy &

> paste.

>

> Kaj

Kaj,

There is some backstory you are missing here. I suggest reading the following thread

http://forum.java.sun.com/thread.jspa?threadID=769644

cotton.ma at 2007-7-21 11:03:01 > top of Java-index,Java Essentials,Java Programming...
# 22
> There's more than one way to skin a cat.But not all of them are good. Your code is hard to follow and maintain.
kajbja at 2007-7-21 11:03:01 > top of Java-index,Java Essentials,Java Programming...
# 23

> > > >

> > > > Do you think you are helping?

> > >

> > > I sure do. Hey, I don't know swing at all. She

> > > still has to do that part.

> >

> > How much do you think the OP is learning if he

> > doesn't give it a try on his own? The only thing

> that

> > he will learn if you write the code for him is copy

> &

> > paste.

> >

> > Kaj

>

> I don't care what they learn. That's up to them.

> I'm not the learning police.

This is true. You have planted yourself firmly with the Ulrika gestapo.

cotton.ma at 2007-7-21 11:03:01 > top of Java-index,Java Essentials,Java Programming...
# 24
> > There's more than one way to skin a cat.> > But not all of them are good. Your code is hard to> follow and maintain.He doesn't care.
cotton.ma at 2007-7-21 11:03:01 > top of Java-index,Java Essentials,Java Programming...
# 25
> I don't care what they learn. That's up to them.> I'm not the learning police.This sounds very similar to "I post here to amuse myself".
aniseeda at 2007-7-21 11:03:01 > top of Java-index,Java Essentials,Java Programming...
# 26

> Why not change it to..

> > public static boolean isPalindrome(String text) {

> return text.equals(new

> ew StringBuilder(text).reverse().toString());

> }

>

>

> Kaj

My way is also 3-4 times faster ;-)

Norweeda at 2007-7-21 11:03:01 > top of Java-index,Java Essentials,Java Programming...
# 27
> There is some backstory you are missing here. I> suggest reading the following thread> > http://forum.java.sun.com/thread.jspa?threadID=769644Thanks. But why is he posting crappy code if he wants to help?
kajbja at 2007-7-21 11:03:01 > top of Java-index,Java Essentials,Java Programming...
# 28
And neither code fulfills the GUI requirement. :)
CeciNEstPasUnProgrammeura at 2007-7-21 11:03:01 > top of Java-index,Java Essentials,Java Programming...
# 29
> > There's more than one way to skin a cat.> > But not all of them are good. Your code is hard to> follow and maintain.OK, how about this. My way is a good bit faster than yours.....:rolleyes:
Norweeda at 2007-7-21 11:03:01 > top of Java-index,Java Essentials,Java Programming...
# 30

> > There is some backstory you are missing here. I

> > suggest reading the following thread

> >

> >

> http://forum.java.sun.com/thread.jspa?threadID=769644

>

> Thanks. But why is he posting crappy code if he wants

> to help?

I think because

a) he doesn't know any better

b) he doesn't care because the OP failing is his goal in the end

So help is sort of a subjective term in this instance.

cotton.ma at 2007-7-21 11:03:06 > top of Java-index,Java Essentials,Java Programming...
# 31
> And neither code fulfills the GUI requirement. :)I never said it did. I'm not about to write and swing code. Not my thing.
Norweeda at 2007-7-21 11:03:06 > top of Java-index,Java Essentials,Java Programming...
# 32

> Thanks. But why is he posting crappy code if he wants

> to help?

Did I mention that he's just holding a grudge and wants to try all he can to tick me off?

He's not interested in helping people. He's relegated himself to the position of homework slave to see if he can tick me off. It's fun to watch, kind of.

warnerjaa at 2007-7-21 11:03:06 > top of Java-index,Java Essentials,Java Programming...
# 33
> OK, how about this. My way is a good bit faster than> yours.....:rolleyes:Why write code which is hard to follow before you know that the performance is a problem?
kajbja at 2007-7-21 11:03:06 > top of Java-index,Java Essentials,Java Programming...
# 34

> Thanks. But why is he posting crappy code if he wants to help?

It's not crappy, it's geeky I'd say. It is more efficient, but it looks like it's from someone with a background in C++. :)

I don't like homework being solved that way here - it helps neither us nor them (in fact, it'll keep traffic high, since there's more than one assignment) - but the code itself is good. Could be much worse.

CeciNEstPasUnProgrammeura at 2007-7-21 11:03:06 > top of Java-index,Java Essentials,Java Programming...
# 35

NO, it's not just to tick you off. I was doing it before you went crazy. Maybe it's to take away a little bit of the power trip some of you guys have when total noobs post.

I agree what I'm doing is probably not going ot be helpful to anyone, but it's better than reading the same drivel from the same people over and over again.

Norweeda at 2007-7-21 11:03:06 > top of Java-index,Java Essentials,Java Programming...
# 36
> I agree what I'm doing is probably not going ot be> helpful to anyone, but it's better than reading the> same drivel from the same people over and over again.We love you too sweetheart.
cotton.ma at 2007-7-21 11:03:06 > top of Java-index,Java Essentials,Java Programming...
# 37

> > Thanks. But why is he posting crappy code if he

> wants to help?

>

> It's not crappy, it's geeky I'd say. It is more

> efficient, but it looks like it's from someone with a

> background in C++. :)

>

> I don't like homework being solved that way here - it

> helps neither us nor them (in fact, it'll keep

> traffic high, since there's more than one assignment)

> - but the code itself is good. Could be much worse.

Well thank you for at least being honest :-D

Norweeda at 2007-7-21 11:03:06 > top of Java-index,Java Essentials,Java Programming...
# 38

> Maybe it's to take away a

> little bit of the power trip some of you guys have

> when total noobs post.

LOL

> I agree what I'm doing is probably not going ot be

> helpful to anyone, but it's better than reading the

> same drivel from the same people over and over again.

better in what sense?

If someone wants readymade solutions, they should be rightly directed to http://www.geekinterview.com/

aniseeda at 2007-7-21 11:03:06 > top of Java-index,Java Essentials,Java Programming...
# 39

>if ( PALINDROME_LENGTH % 2 == 1 )

>{

> halfLength = (PALINDROME_LENGTH - 1) / 2;

> }

> else

> {

> halfLength = PALINDROME_LENGTH / 2;

I don't see how that is any different from this:halfLength= PALINDROME_LENGTH/2;

I find the first version so verbose and confusing. btw, as Kaj already

had shown: there are better, more concise ways to figure out if

something is a palindrome or not. Please don't post home brew

solutions, especially not when they are wobbly and also especially not

when the OP can't learn anything from it. You are not doing the new

folks around a favour.

kind regards,

Jos

JosAHa at 2007-7-21 11:03:06 > top of Java-index,Java Essentials,Java Programming...
# 40
> If someone wants readymade solutions, they should be> rightly directed to http://www.geekinterview.com/Well apparantly that's not true anymore, now that we have a homework slave among us.Dance, Jerkweed, dance!
warnerjaa at 2007-7-21 11:03:06 > top of Java-index,Java Essentials,Java Programming...
# 41

> >if ( PALINDROME_LENGTH % 2 == 1 )

> >{

> > halfLength = (PALINDROME_LENGTH - 1) / 2;

> > }

> > else

> > {

> > halfLength = PALINDROME_LENGTH /

> 2;

> I don't see how that is any different from

> this:> halfLength= PALINDROME_LENGTH/2;

>

> I find the first version so verbose and confusing.

> btw, as Kaj already

> had shown: there are better, more concise ways to

> figure out if

> something is a palindrome or not. Please don't post

> home brew

> solutions, especially not when they are wobbly and

> also especially not

> when the OP can't learn anything from it. You are not

> doing the new

> folks around a favour.

>

> kind regards,

>

> Jos

Yup x/2 works a lot better. I like all the code analysis, pick it appart all you like, fine with me. I wrote it fast and am bound to make some mistakes. Yu realize by correxting my code you're actually helping the OP any more.

It seems a bit ironic to me. You don't want to do any homework, so I do it, you hate it so I keep doing it, you hate that I do it and thus correct my code trying to make me feel stupid in the hopes that I'll go away, however, in the end you're acutally just helping the OP get better code.

Good work guys.

Norweeda at 2007-7-21 11:03:06 > top of Java-index,Java Essentials,Java Programming...
# 42

> > Thanks. But why is he posting crappy code if he

> wants to help?

>

> It's not crappy, it's geeky I'd say. It is more

> efficient, but it looks like it's from someone with a

> background in C++. :)

Hush. I'm trying to poke him with a stick. I want to see him upset :)

kajbja at 2007-7-21 11:03:06 > top of Java-index,Java Essentials,Java Programming...
# 43

> I agree what I'm doing is probably not going ot be

> helpful to anyone, but it's better than reading the

> same drivel from the same people over and over again.

Oh, yes, totally. I can't believe the drivel that people post. **** like, "Try to do it yourself, then post what you've got and ask specific questions about the suff that's giving you trouble." What a bunch of malarkey! How dare we keep repeating that same old nonsense to these poor beleagured posters!

jverda at 2007-7-21 11:03:06 > top of Java-index,Java Essentials,Java Programming...
# 44
> It seems a bit ironic to me. You don't want to do> any homework, so I do it, you hate it so I keep doing> it, you hate that I do it and thus correct my codeThe difference is that the code which I posted probably won't be accepted by his professor.
kajbja at 2007-7-21 11:03:07 > top of Java-index,Java Essentials,Java Programming...
# 45

> > I agree what I'm doing is probably not going ot be

> > helpful to anyone, but it's better than reading

> the

> > same drivel from the same people over and over

> again.

>

> Oh, yes, totally. I can't believe the drivel that

> people post. **** like, "Try to do it yourself,

> then post what you've got and ask specific questions

> about the suff that's giving you trouble." What a

> bunch of malarkey! How dare we keep repeating that

> same old nonsense to these poor beleagured posters!

Good morning Jeff. :)

cotton.ma at 2007-7-21 11:03:11 > top of Java-index,Java Essentials,Java Programming...
# 46

> > It seems a bit ironic to me. You don't want to do

> > any homework, so I do it, you hate it so I keep

> doing

> > it, you hate that I do it and thus correct my code

>

> The difference is that the code which I posted

> probably won't be accepted by his professor.

I don't see why it wouldn't be?

Norweeda at 2007-7-21 11:03:11 > top of Java-index,Java Essentials,Java Programming...
# 47

> > The difference is that the code which I posted

> > probably won't be accepted by his professor.

>

> I don't see why it wouldn't be?

1) The professor will probably notice that it isn't written by a beginner.

2) The professor probably wants the OP to use a loop, so he will tell him to do it using a loop instead.

Kaj

kajbja at 2007-7-21 11:03:11 > top of Java-index,Java Essentials,Java Programming...
# 48

> It seems a bit ironic to me. You don't want to do

> any homework, so I do it, you hate it so I keep doing

> it, you hate that I do it and thus correct my code

> trying to make me feel stupid in the hopes that I'll

> go away, however, in the end you're acutally just

> helping the OP get better code.

Your mind works in a very funny way.

Jos

JosAHa at 2007-7-21 11:03:12 > top of Java-index,Java Essentials,Java Programming...
# 49

> It seems a bit ironic to me. You don't want to do

> any homework, so I do it, you hate it so I keep doing

> it, you hate that I do it and thus correct my code

> trying to make me feel stupid in the hopes that I'll

> go away, however, in the end you're acutally just

> helping the OP get better code.

It would be even ironic when the OP copies the first posted code and gets satisfied and ignores all the refinements. :)

aniseeda at 2007-7-21 11:03:12 > top of Java-index,Java Essentials,Java Programming...
# 50
thanks a lot... :D
kathleenkatea at 2007-7-21 11:03:12 > top of Java-index,Java Essentials,Java Programming...
# 51
> thanks a lot... :D*snort*
cotton.ma at 2007-7-21 11:03:12 > top of Java-index,Java Essentials,Java Programming...
# 52
> Your mind works in a very funny way.> > JosSure does.
Norweeda at 2007-7-21 11:03:12 > top of Java-index,Java Essentials,Java Programming...