473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

palindrome, if the user inputs "what" the output is "thaw"

3
i can hardly know what is the code for this. I have researched palindromes, but unfortunately, I only have read about integers not for characters..I need some help..
Feb 23 '07 #1
9 4006
r035198x
13,262 8TB
i can hardly know what is the code for this. I have researched palindromes, but unfortunately, I only have read about integers not for characters..I need some help..
There are many ways of doing this.
Surely you must have an idea of your own on how to do it? Let's start with the more difficult one. If you were told to this this by making use of a char array, how would you do it?
Feb 23 '07 #2
abctech
157 100+
i can hardly know what is the code for this. I have researched palindromes, but unfortunately, I only have read about integers not for characters..I need some help..
Are you trying to write a code to reverse a string or to check if a given word is a palindrome?

As far as I know a palindrome is a word, phrase, verse, or sentence that reads the same backward or forward.
Eg: Dad, Madam, "fall leaves after leaves fall" etc
Feb 23 '07 #3
hirak1984
316 100+
well I am not sure if this can be called a plaindrome
"fall leaves after leaves fall"
I am putting some more examples...
Don't nod
Dogma: I am God
Never odd or even
Too bad – I hid a boot
Rats live on no evil star
No trace; not one carton
Was it Eliot's toilet I saw?
Murder for a jar of red rum
May a moody baby doom a yam?
Go hang a salami; I'm a lasagna hog!
Satan, oscillate my metallic sonatas!
A Toyota! Race fast... safe car: a Toyota
Straw? No, too stupid a fad; I put soot on warts
Are we not drawn onward, we few, drawn onward to new era?
Doc Note: I dissent. A fast never prevents a fatness. I diet on cod
No, it never propagates if I set a gap or prevention
Anne, I vote more cars race Rome to Vienna
Sums are not set as a test on Erasmus
Kay, a red nude, peeped under a yak
Some men interpret nine memos
Campus Motto: Bottoms up, Mac
Go deliver a dare, vile dog!
Madam, in Eden I'm Adam
Oozy rat in a sanitary zoo
Ah, Satan sees Natasha
Lisa Bonet ate no basil
Do geese see God?
God saw I was dog
Dennis sinned
Are you trying to write a code to reverse a string or to check if a given word is a palindrome?

As far as I know a palindrome is a word, phrase, verse, or sentence that reads the same backward or forward.
Eg: Dad, Madam, "fall leaves after leaves fall" etc
Feb 23 '07 #4
abctech
157 100+
"fall leaves after leaves fall"
well I am not sure if this can be called a plaindrome
Word palindromes are sentences that are read in either direction word by word.
Eg:
First ladies rule the state, and state the rule,"Ladies First."
Fall leaves after leaves fall.

Ref:-
You can find the above examples under 'Symmetry by words' in http://en.wikipedia.org/wiki/Palindrome
Feb 23 '07 #5
r035198x
13,262 8TB
Alright then. I'll copy this to the cafe forum.
Feb 23 '07 #6
Dullme
3
Expand|Select|Wrap|Line Numbers
  1. import java.io.*;
  2.   public class Pal
  3.  {
  4.     public static void main (String args[])throws Exception
  5.   {
  6.     String character;
  7.     //char word;
  8.      char[] temp; 
  9.      temp = new char[15];
  10.      char i;
  11.  
  12.         System.out.println("Input word:");
  13.         for (i=0;i<14;i--) 
  14.          {
  15.               InputStreamReader word= new InputStreamReader(System.in);
  16.               BufferedReader word2=new BufferedReader(word);
  17.               character=word2.readLine();
  18.               //character=String.parseInt(character);
  19.               //temp[i]=character;
  20.          }
  21.               //System.out.println ("Palindrome: ");
  22.                 for (i=0;i<14;--i)
  23.              {
  24.                System.out.print ("Palindrome: "+temp[i]);    
  25.               }              
  26.   }
  27.  }
That is my code.My problem is that, how can I make the user's word input to its opposite word? Example: He inputs MILK.. The output shoud be KLIM.
Please help!
Mar 6 '07 #7
r035198x
13,262 8TB
Expand|Select|Wrap|Line Numbers
  1. import java.io.*;
  2. public class Pal
  3. {
  4. public static void main (String args[])throws Exception
  5. {
  6. String character;
  7. //char word;
  8.     char[] temp; 
  9.     temp = new char[15];
  10.     char i;
  11.  
  12. System.out.println("Input word:");
  13.         for (i=0;i<14;i--) 
  14.     {
  15.           InputStreamReader word= new InputStreamReader(System.in);
  16.         BufferedReader word2=new BufferedReader(word);
  17.         character=word2.readLine();
  18.         //character=String.parseInt(character);
  19.         //temp[i]=character;
  20.     }
  21.      //System.out.println ("Palindrome: ");
  22.      for (i=0;i<14;--i)
  23.     {
  24.           System.out.print ("Palindrome: "+temp[i]);    
  25.          } 
  26. }
  27. }
That is my code.My problem is that, how can I make the user's word input to its opposite word? Example: He inputs MILK.. The output shoud be KLIM.
Please help!
Get the word as a string with the readline method. No need for a for loop for that.
Then get its length using the string.length() method. After that you can now form a string by adding characters from the last to the first using a for loop.
Mar 6 '07 #8
example codes of palindrome in NetBeans with interface
Mar 8 '07 #9
r035198x
13,262 8TB
example codes of palindrome in NetBeans with interface
Write them yourself like the OP is trying to do here. You will learn better that way.
Mar 8 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Dullme | last post by:
i can hardly know what is the code for this. I have researched palindromes, but unfortunately, I only have read about integers not for characters..I need some help..
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.