Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Program to display palindrome numbers between some range
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Sowndarya
Program to display palindrome numbers between some range
1 Answer(s)      3 years and 7 months ago
Posted in : Java Beginners


Hi!I want a java program to display palindrome numbers between 100 to 1000.can you please explain me the logic with an example


Advertisement
View Answers

May 9, 2011 at 4:32 PM


import java.util.*;

public class NumberPalindrome {
    static ArrayList<Integer> list = new ArrayList<Integer>();
public static   ArrayList<Integer> findPalindromes(){
             for (int i=100; i<=1000; i++){
             Integer in=new Integer(i);
             String number=in.toString();
             int index1=0;
             int index2=number.length()-1;
             char x=number.charAt(index1);
             char y=number.charAt(index2);
             while (index2-index1>=0){
             if(x!=y)
             break;
             if (index2-index1==0 || index2-index1==1)
             list.add(i);
             index1++;
             index2--;
             x=number.charAt(index1);
             y=number.charAt(index2);
             }
          }
          return list;
       }
    public static void main(String[] args) {
   ArrayList l=findPalindromes();
   for(int i=0;i<l.size();i++){
       System.out.println(l.get(i));
   }
    }
}


Related Tutorials/Questions & Answers:
Program to display palindrome numbers between some range
Program to display palindrome numbers between some range  Hi!I want a java program to display palindrome numbers between 100 to 1000.can you please explain me the logic with an example   import java.util.*; public
print the even numbers between the range 100-200
print the even numbers between the range 100-200  Q ?write an application that print out the even numbers between the range 100-200 ? 1- which aer... prints out the even numbers between the range of 100 and 200 and then determine
Advertisements
write an application that print out the even numbers between the range 100-200
write an application that print out the even numbers between the range 100-200   write an application that print out the even numbers between... and determine the even numbers between them. class EvenNumbers { public static
Finding all palindrome prime numbers - Java Beginners
Finding all palindrome prime numbers  How do i write a program to Find all palindrome prime numbers between two integers supplied as input (start and end points are excluded
palindrome
palindrome  write a program to print palindrome numbers between 500 to 700
Prime Numbers from range
Prime Numbers from range  how to find prime numbers in a given range which are palindromes??   Hi Friend, Try the following code: import java.util.*; public class PrimeAndPalindrome { static final int MAXNUMBER
Generating random numbers in a range with Java
Generating random numbers in a range with Java  Generating random numbers in a range with Java
Write a program to list all even numbers between two numbers
Write a program to list all even numbers between two numbers... Numbers Example in Java: Here you will learn to write a program for listing out all the even numbers between two numbers. For this first create a class named
Palindrome program in Java
Palindrome program in Java helps programmers to determine if a number.... The logic used in Java program behind finding a number or sting is palindrome... entered is palindrome or not. If the given number is larger, then it will display
Palindrome
Palindrome  program to verify palindrome
Listing all even numbers between two numbers
the numbers. Check the tutorial Write a program to list all even numbers between two...Listing all even numbers between two numbers  Hi, How to write code to list all the even numbers between two given numbers? Thanks   Hi
Find Numbers which are palindrome and prime
Find Numbers which are palindrome and prime In this section, you will learn how to find the numbers from 1 to 500 which are palindrome and prime. To compute...() of boolean type. Now the list contains all the numbers which are palindrome
palindrome
palindrome  program to find the given string is palindrome...]; } if(st.equalsIgnoreCase(reversedSt)){ System.out.println("String is palindrome"); } else{ System.out.println("String is not palindrome
palindrome
palindrome  how to write in string of palindrome?   import... is palindrome"); } else{ System.out.println("String is not palindrome
palindrome
palindrome  how to write in string of palindrome   import... is palindrome"); } else{ System.out.println("String is not palindrome
PALINDROME
PALINDROME  how to find palindrome of a number WITHOUT using a string... == reversedNumber){ System.out.print("Number is palindrome!"); } else{ System.out.println("Number is not palindrome!"); } } catch(Exception e){ System.out.println(e
generate random numbers and display the largest
generate random numbers and display the largest  Hi, I am using netbeans so if someone could help me with an answer in that form i'd appreciate it. Write a method to find the largest value in an array. Write a program that takes
mysql difference between two numbers
mysql difference between two numbers  How to get total bate difference between two dates for example 1/01/2012 and 1/02/2012 in MYSQL?   ... between two date. The syntax of DATEDIFF is .. SELECT DATEDIFF('2012-01-31 23:59
Java Program to check Palindrome
Java Program to check Palindrome In this section, you will learn about..., then it is called palindrome number otherwise it is not. Description of program : With the help of this program, we are going to check whether the number is palindrome
prime palindrome
prime palindrome  Hi I want to write a program that ask a user to input a number, the program then list all the prime numbers that are palindrome below the number entered. In pascal language Thanks
Java program - convert words into numbers?
Java program - convert words into numbers?   convert words into numbers?   had no answer sir
java palindrome
java palindrome  sir i need java program to print 1)integer palindrome 2)string palindrome
How do I change the while loop in this code to the range with range list style display page for a resultSet() in jsp?
How do I change the while loop in this code to the range with range list style display page for a resultSet() in jsp?  this is count record code <%@ page language="java" import="java.sql.*" %> <html> <head>
SQL display date in between query
SQL display date in between query  how to get ( 15 march 2011) and (15/03/2011) output using SQL
The Array Palindrome Number in Java
The Array Palindrome Number in Java       This is a Java simple palindrome number program... program. The array palindrome number arrange the array number. This session
palindrome - Java Beginners
palindrome  example of java program if it is a palindrome or not palindrome   Hi friend, Example to check the number is a palindrome...){ System.out.print("Number is palindrome!"); } else
To check a palindrome number?
To check a palindrome number?  program to check a number is palindrome or not using recursion?(wihout converting to string
prime palindrome
prime palindrome  Hi I want to write a program in pascal that ask a user to input a number, the program then list all the prime number that are palindrome below the number entered. thks
MySQL range
some range. To fire query we must have some data into a table therefore we... MySQL range       May times the programmer needs to find out some specific data which lies
Palindrome Number Example in Java
or not. If the given number is larger, then it will display a message "Out of range... Palindrome Number Example in Java    ... the palindrome number and how to determine any number is palindrome or not. First of all we
display dates between two dates - Java Beginners
display dates between two dates  hi can any one help me to writing this code, i need to store the dates between to dates so that i can retrive the data from the db using theses dates. its urgent pls tell me as possible
 

 

 

DMCA.com