File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes I need help in writing program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I need help in writing program" Watch "I need help in writing program" New topic
Author

I need help in writing program

Ken smith
Greenhorn

Joined: Jun 01, 2006
Posts: 8
I have to write a program that inputs 5 dogit integer from the keyboard and print if the input is a palindrome or not.

Example

12921 is a palindrome.
12923 is not palindrome


Can someone please with this problem. I'm new to this game. Thanks in advance.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Anal sex at noon taxes Lana. (extra credit)

What have you written so far? This isn't a "do my homework for me" forum. Those are located here.
[ June 01, 2006: Message edited by: Jeff Albertson ]

There is no emoticon for what I am feeling!
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

"MAGICTECHH MAGICTECHH,"

Welcome to JavaRanch!

Please revise your display name to meet the JavaRanch Naming Policy. To maintain the friendly atmosphere here at the ranch, we like folks to use real (or at least real-looking) names, with a first and a last name.

You can edit your name here.

Thank you for your prompt attention, and enjoy the ranch!

-Marc


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Wolfgang Obi
Ranch Hand

Joined: Dec 05, 2005
Posts: 134
Originally posted by Jeff Albertson:
Anal sex at noon taxes Lana. (extra credit)

What have you written so far? This isn't a "do my homework for me" forum. Those are located here.

[ June 01, 2006: Message edited by: Jeff Albertson ]


wow u even took the pains to supply him a link *lol*....

*shakes head @ Jeff*
Ken smith
Greenhorn

Joined: Jun 01, 2006
Posts: 8
I'm not trying to get people to do my home work for me. I just need help resolving this problem. I've red several documents regarding the topic; however, I'm still having problems. Any help would be greatly appreciated.
Regards

Ken
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Originally posted by Wolfgang Obi:


wow u even took the pains to supply him a link *lol*....

*shakes head @ Jeff*


I'm hoping he goes there and doesn't come back until he learns his lesson. Or should I have quoted Groucho Marx: "Go and never darken my towels again"?
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Originally posted by Ken smith:
I'm not trying to get people to do my home work for me. I just need help resolving this problem. I've red several documents regarding the topic; however, I'm still having problems. Any help would be greatly appreciated.
Regards


Okay. Lots of first-time posters do come here looking for someone to do their homework for them. If we are to give you the benefit of a doubt, you should post specific questions and post your code.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11230
    
  16

we will be happy to help you with your homework. what have you done so far? what do you know how to do? can you write the "hello, world" program, compile it, and get it to run?

how far into the assignment have you gotten? do you know what a palindrome is? if so, how would you test a set of characters (not programatically, but in your head - use words)

as you can see, we just don't have enough info yet on HOW to help you. so, answer a few of my questions above, show us what (if any) code you've written, and ask SPECIFIC questions. ask as many of those as you want, and somebody will help you with all of them.

but a generic "here's the assignment, what should i do" will not get you many (helpful) responses.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
This very programming example is part of Java Tutorial on Object Basics and Simple Types. I recommend going through the entire Tutorial


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Ken smith
Greenhorn

Joined: Jun 01, 2006
Posts: 8
Here is the code that I've written. I'm trying to test if the y variable is a palindrome or if it's not. As you guys can see, I'm trying. Please help. Regards Ken

Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Before you actually start writing code for a problem you don't totally understand, it would be to your advantage to sit down with paper and pencil and consider how you would solve the problem without a computer.

Once you understand how to solve it, it will be easy to code.
Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
Since you are manipulating ints, look up / and % operators, and see if you can figure out how to "take apart" your integer.

A String is bit easier to manipulate and StringBuffer easier as well. If you aren't required to test from an integer directly, look up the available methods to see how it could be done.

You didn't mention if you understand what a palidrome is. If you do, do what another poster suggested, write down the steps you think it takes to do this, Then refine it into psuedocode. Test the psuedocode on paper, then write the code.

If you need more help, please ask more specific questions.
[ June 01, 2006: Message edited by: Rusty Shackleford ]

"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
Ken smith
Greenhorn

Joined: Jun 01, 2006
Posts: 8
If there is any guru out there, all I need is a solution to my problem. Not links to some study materia. As I said earlier, I've red lots of java intro documents. If you know how to code in jave please help.
Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
What happened to: "I'm not trying to get people to do my home work for me"?

If someone wrote out the code for you, and I am willing to bet that everyone who responding could write it in 5 minutes or less, what good will that do you? Even I could, and am not close to "guru" level. You have shown very little attempt at a solution. The entire core of the problem has no code at all, not even a wrong attempt.

If you come up with the solution, with hints and pointers from others, you will have learned far more then if someone just gives you the solution. I assume the point of this is that you want to learn.

There are plenty of majors out there that don't require a ton of thought or ability to problem solve. Any program that requires you to program is not one of them. This assignments point(as are most) is to learn how to effectively solve problems, that is what programming is. There are not always easy answers, nor is there just one answer.

If you get a good grade and learned nothing, how will that help? Programming is cumulative, assignments often build on the others. So for the next one, you will likely be back on a message board begging for a solution. If you somehow get through your program doing this; and it is possible,I have seen it, what you will do at a job?

*hops off soapbox*

Start with what you know. ie what is a palindrome? Use the definition and properties, if any, and build from there. That is what you need to do with any algorithm, proof, physics/math problem, ect.

Now set your requirements, is it stored as a String or int for example. Then figure out how to do the necessary comparisons. Is there a guarantee that the number will not exceed a certain value(other then the set limit for int)? Do you need a loop to do this? or just a few if statements? What happens if the length of the integer is an odd or even number, does it matter(ie 123 is length 3)?

Keep thinking about it, and post specific questions and show what you have done.
[ June 01, 2006: Message edited by: Rusty Shackleford ]
Ken smith
Greenhorn

Joined: Jun 01, 2006
Posts: 8
Rusty,

You sound like a nice individual. I understand you genuinely love java programming and want to help people study it the right way. I'm taken java programming for quiet a few reasons; get college credit and maybe use the knowledge to write little scripts in other platforms. I have absolutely no desire to becoming a java programmer or any type of programmer in general. I've been working as a SQL Sever DBA for about fifteen years now. I've been writing T-SQL scripts for a long as I can remember. Currently, I'm sick of any technical related careers. The reason I'm trying to finish my degree program is just so I can go to law school.
Again, I'm doing my best to study and understand java programming, but my instructor suck. Regard Ken
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

There are some very helpful methods in the String class that will allow you to "get at" the individual characters.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I need help in writing program