Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 26th, 2012, 08:04 AM
Anon1432 Anon1432 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 1 Anon1432 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 5 sec
Reputation Power: 0
Homework - Array for Palindrome

Hi, I was wondering if anyone could help me with this. We were given the following layout and have to fill in the rest to make the array program for palindromes to work but I just can't get it to!

public class palindrome
{
public static void main(String[] args)
{
int i;
int j;
int palindromeSize=;//ENTER NUMBER OF LETTERS IN SUSPECTED PALINDROME
char palindrome[]=new char[palindromeSize];//Create array to hold the characters of a palindrome to be tested

//ENTER CHARACTERS OF PALINDROME INTO ARRAY
for)
}
{


palindrome[i]=inputCharacter;

}
System.out.print("The word or phrase to be tested is: ");
//traverse the array to print out the suspected palindrome
for()
{

;
}
System.out.println();
//A palindrom is tested by comparing first and last letter, second and second last letter etc until middle
for()
{
if()
{
System.out.println("and it is not a palindrome! ");
break;

}
if()//middle of word is reached
{
System.out.println("and it is a palindrome!");
}
}
}
}

Reply With Quote
  #2  
Old November 26th, 2012, 08:24 AM
Jacques1's Avatar
Jacques1 Jacques1 is offline
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,875 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 3 h 35 m 16 sec
Reputation Power: 813
Hi,

so what's your approach? What did you try? Where exactly did you have problems?

Please note that this is not a homework service, so we won't give you a solution for you to copy and paste or something. We can help you with concrete questions, but you have to do the actual programming.

Reply With Quote
  #3  
Old November 26th, 2012, 08:29 AM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,956 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 56 m 11 sec
Reputation Power: 345
It'd help if you'd edit your post and wrap the code in code tags.

Reply With Quote
  #4  
Old November 26th, 2012, 09:07 AM
cyimking cyimking is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 29 cyimking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 19 m 56 sec
Reputation Power: 0
Palidromes arent that diffucult. Since its fill in the blank, it makes it easier..

Now i do not know why you have an array for this activity. You could always just ask the user for a string, then give set that string to a string primitive..

Code:
System.out.println("Enter a string: ");
        String value = scan.nextLine();


Then do a loop, which checks the string length and if the length is equal to one, then its a palindrome if not then simply have it loop through a comparison of the first letter with the last letter (best idea to use char and substring), then if it doesnt equal then break out of the loop and say its not a palindrome..

Hopefully that made some sense.

Reply With Quote
  #5  
Old November 26th, 2012, 09:43 AM
Jacques1's Avatar
Jacques1 Jacques1 is offline
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,875 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 3 h 35 m 16 sec
Reputation Power: 813
Quote:
Originally Posted by cyimking
Hopefully that made some sense.


Great. You've basically repeated the code comments and the given layout.

Bursting in with a "solution" when others have just asked the OP for his own thoughts is also not very nice.

Reply With Quote
  #6  
Old November 28th, 2012, 03:53 AM
toddyaww toddyaww is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 8 toddyaww Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 h 28 m 48 sec
Reputation Power: 0
Array for Palindrome

I think Array are use for define any big size ratio in easiest way. Palindrome array is advance of array function.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Homework - Array for Palindrome

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap