civic
civic
Just change the number assigned to P if you want a different number of palindromes: public class PalindromeNumbers { public static final int P = 50; public static void main(String[] args) { getNums(P); } public static void getNums(int n) { int count = 0, current = 1; while(count < n) { if(palindrome("" + current) { System.out.println(current); count++; } current++; } public static boolean palindrome(String s) { if(s.length() s.charAt(s.length - 1) return palindrome(s.substring(1, s.length - 2) else return false; } }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Vector; /** * */ /** * @author omnipath * */ public class Palindrome { /** * @param args */ public static void main(String[] args) { // open up standard input BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String string = null; // readLine() method try { string = br.readLine(); } catch (IOException ioe) { System.out.println("IO error trying to read input!"); System.exit(1); } Palindrome palindromeCase = new Palindrome(string); System.out.println("The longest palindrome is: " + palindromeCase.palindrome); System.out.println("The length of the longest palindrome is: " + palindromeCase.palindrome.length()); System.out.println("Counter is: " + palindromeCase.PalindromeCounter); } String originalString; String palindrome; Vector vectPalindromes; int palindromeLength; int PalindromeCounter; public Palindrome(String s) { PalindromeCounter = 0; this.palindrome = ""; this.palindromeLength = this.palindrome.length(); this.originalString = s; this.calculateLongestPalindrome(s); } public void calculateLongestPalindrome(String s) { if (s.length() == 1) { this.palindrome = this.originalString; this.palindromeLength = this.palindrome.length(); } this.parseForPalindrome(this.originalString); } public void parseForPalindrome(String s) { PalindromeCounter++; if (s.length() -1; i--) { sb.append(s.charAt(i)); } return sb.toString(); } }
import java.util.Scanner; public class Palindrome{ public static void main(String[] args){ String front; String back =""; char[] failure; String backwards; Scanner input=new Scanner(System.in); System.out.print("Enter a word: "); front=input.next(); front=front.replaceAll(" ", ""); failure=front.toCharArray(); for (int i=0; i<failure.length; i++){ back=failure[i] + back; } if (front.equals(back)){ System.out.print("That word is a palindrome"); }else System.out.print("That word is not a palindrome"); }}
No, it isn't a palindrome.
There is no palindrome for 14.
The palindrome is Level.
Any number that is is a palindrome will always be a palindrome.
No. A palindrome reads the same backwards and forwards. 5791111975 is an example of a palindrome.
1998 is not and cannot be a palindrome.
"radar" is a palindrome for detector.