Share on Google+Share on Google+

2 Answer(s)      8 years ago
Posted in : Java Beginners
View Answers

March 12, 2009 at 5:19 AM

Hi friend,

Code to help in solving the problem :

import java.io.*;
class Plaindrome
public static void main(String[] args)

String string = "";
InputStreamReader input = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(input);
// read in user input
boolean bool=false;

System.out.println("Please enter 5 digit number.");
string = reader.readLine();
catch(Exception e){}
int num=Integer.parseInt(string);
int rev=0;
int rem=0;
int n = num;

System.out.println("Please enter again valid number");


March 13, 2009 at 1:21 AM

Hi Friend

This is the full code according to your full requirement.

// Code Starts

import javax.swing.*;
import java.awt.event.*;

public class Pallindrome{
public static void main(String[] args){
JFrame frame = new JFrame("Calculate Pallindrome");
JButton button = new JButton("Calculate Pallindrome");
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
String str = JOptionPane.showInputDialog(null, "Enter some number : ", "", 1);
if(str.length() <= 4){
JOptionPane.showMessageDialog(null, "You have entered a " + str.length() + " digit number.", "Calculate Pallindrome", 1);
} else {
int num = Integer.parseInt(str);
int n = num;
int rev=0;
for (int i=0; i<=num; i++){
int r=num%10;
if(n == rev){
JOptionPane.showMessageDialog(null, "Number is pallindrome", "Calculate Pallindrome", 1);
JOptionPane.showMessageDialog(null, "Number is not pallindrome", "Calculate Pallindrome", 1);
JPanel panel = new JPanel();
frame.setSize(400, 400);

// Code Ends

Thanks and Regards
RoseIndia Team


Related Tutorials/Questions & Answers:
examples  Hi sir...... please send me the some of the examples... questions .   Hello Friend, Which type of connectivity examples do you want?Please clarify this. Thanks   mysql connectivity examples  
PHP Examples
In this section of PHP examples, the new bees will learn the basic examples of most common used functions. These examples will help to the experts too... examples from several functions to sessions, class and objects. The examples
HTML5 examples
examples to learn in detail with the help of many examples. Please provide me the urls of HTML5 examples. Thanks   Hi, There are many new features... supported by major browsers. View examples at HTML5 Examples tutorial page
examples for overloading and overriding
examples for overloading and overriding  examples for overloading and overriding
Ajax examples
Ajax examples  Hi, I am Java programmer and I have done programming in Java. Now I am learning ajax from scratch. Tell me the good examples of Ajax. Thanks   Hi, Since you have already experience in development
Version of drools-examples>drools-examples dependency
List of Version of drools-examples>drools-examples dependency
need ENUM examples
need ENUM examples  i need enum sample examples
Examples on threads and mulithreading.....
Examples on threads and mulithreading.....  Is any good examples on threads and Mulithreading...   Hi Friend, Please visit the following link: Thread Tutorial Thanks
Version of excalibur-component-examples>excalibur-component-examples dependency
List of Version of excalibur-component-examples>excalibur-component-examples dependency
Javascript Examples
JavaScript Examples     Clear cookie example Cookies can... In this part of JavaScript examples, we have created a simple example which shows the use... discussed in our previous examples the use of getAttribute() method. Visit the link
need ENUM examples
need ENUM examples  i need enum sample examples   Hi Friend, Visit Here Thanks
need ENUM examples
need ENUM examples  i need enum sample examples   Hi Friend, Visit Here Thanks
unable to execute the examples
unable to execute the examples  unable to execute the examples given for struts,ejb,or spring tutorials.Please help I am a beginner
Criteria Query Examples in Hibernate
Criteria Query Examples in Hibernate  How to use the Criteria Query... Criteria Query in Hibernate with Examples code. Check the tutorial Criteria Query Examples. Check the Latest tutorials, articles and examples of Hibernate
Java Tutorial with examples
Java Tutorial with examples  What is the good urls of java tutorial with examples on your website? Thanks   Hi, We have many java tutorial with examples codes. You can view all these at Java Example Codes
Artifacts of drools-examples
List of Artifacts of drools-examples maven depenency
Artifacts of excalibur-component-examples
List of Artifacts of excalibur-component-examples maven depenency
Ajax website examples
Ajax website examples  Hi, Provide me the url's of ajax website examples. Thanks   Hi, Please see the nice Login and Registration page of Roseindia.net, which demonstrate the capabilities of Ajax frameworks. Thanks
Examples of optical disk
Examples of optical disk  What is the example of Optical disk? Please give me at least one example of it.   Digital versatile disks is a example of optical disk
HTML5 examples.
HTML5 quick examples. HTML5 Examples, Definition of <!DOCTYPE > in HTML5. HTML5 comment tag Example,, Definition of <!--  --> comment tag.... HTML5 input examples, Introduction and implementation of input tag. HTML5
HTML form examples
HTML form examples  Hi, How to create a simple data entry form in HTML and use JavaScript to validate the same. Can anyone share html form examples code? Thanks   Hi, Please see the HTML form example page. Thanks
Hibernate Associations and Joins Examples
Hibernate Associations and Joins Examples  How to write examples of Associations and Joins in Hibernate? Thanks   Hi, Please check the tutorial Associations and Joins. This tutorial explains you about Associations
What is outer join?Explain with examples.
What is outer join?Explain with examples.  What is outer join?Explain with examples
need ENUM examples
need ENUM examples  i need enum sample examples   Hi Friend, Try the following code: public class EnumExample { public enum Languages{ C, Java, DOTNET, PERL } public static void main(String[] args){ int
Need Jar in the JPA examples
Need Jar in the JPA examples  JPA - tutorial is good, very easy to understand and simple. But to run the examples, the jar/helping files are needed. and how Hibernates are used in the JPA example? Thnaks Abhijit Das   
Struts Layout Examples - Struts
Struts Layout Examples  Hi, Iam trying to create tabbed pages using the struts layout tag. I see the tab names on the page but they cannot be clicked on. Im not able to find simple examples/explanation on it. Any help
SQL tutorial with examples
SQL tutorial with examples  Hi, I am looking for good SQL tutorial with examples code. Please give me good urls for SQL tutorial with example code which can be downloaded and easily used. Thanks   Read at SQL Example
PHP Tutorials Guide with Examples
PHP Tutorials Guide with Examples  Hi, I am a beginners in PHP. I have searching for php tutorial guides with examples. Can any one provide me resourceful link. Thanks,   Hi, Please read this PHP tutorial
Maven Dependency drools-examples >> 2.0-beta-15
You should include the dependency code given in this page to add Maven Dependency of drools-examples >> drools-examples version2.0-beta-15 in your project
Dynamic html examples
Dynamic html examples  Hi, What is Dynamic HTML? Explain with dynamic html examples. Thanks   Hi, DHTML stands for Dynamic HTML and is uses the HTML, JavaScript, DOM, & CSS in a program. Following is very simple
javascript event handling examples
javascript event handling examples  javascript event handling examples   var handleClick = function(e) { // Older IEs set the `event` globally. e = window.event || e; // Older IEs use `srcElement` instead


Advertisement null