• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

I need help in writing program

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This very programming example is part of Java Tutorial on Object Basics and Simple Types. I recommend going through the entire Tutorial
 
Ken smith
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ken smith
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 490
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are some very helpful methods in the String class that will allow you to "get at" the individual characters.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic