Ask Experts Questions for FREE Help !
Ask
    Mwenda20's Avatar
    Mwenda20 Posts: 1, Reputation: 1
    New Member
     
    #1

    Jun 28, 2011, 06:38 AM
    How to find a palindrome using java program
    Write a java program that uses a method called palindrome() to determine if number inputs by the user is palindrome or not.
    The numbers inputs can be between 2 to 6 digits long. If the number is 1 or more than 6 digit long the program should be display error and allow a user to enter again. When I tried this program I wrote like this but is not complete.

    import javax.swing.*;
    import javax.swing.JOptionPane;

    public class Test6{

    public static void main(String[] args) {
    //... Local variables
    String Number1;

    Number1 = JOptionPane.showInputDialog(null, "Enter Number.");

    int num = Integer.parseInt(Number1);


    //... calling
    int rever = palindrome(num);

    //... method
    }
    private static int palindrome(int num) {
    int rev;
    rev = num % 10;
    num = num / 10;
    rev = rev * 10 + num;
    System.out.print(" "+ rev);
    if(num==rev)
    System.out.println("The number is palindrome");

    else

    System.out.println("The number is not palindrome");


    return rev;

    }

    }

    Thanks for help

Check out some similar questions!

Postfix program in java [ 0 Answers ]

Java program? [ 2 Answers ]

we have an assignment! but hold up! I would only ask what is the name of this code if I have fill up the blanks! code: puclic class problim{ public static void main(Stringarg){ int x=___; int y=___; while;(__<s){ x=____;

Java program error [ 1 Answers ]

Sir, program is for managing account details using jdbc but ,there error like some variable not accessible in specefic block . Please solve this problem. If you can.. //mypanel1-LogIn class mypanel1 extends JPanel { JTextField t1,t2; JButton b1,b2; mypanel1() { JLabel l1,l2; ...

Error: Java Virtual Machine Launcher "Could not find the main class program will exit [ 3 Answers ]

Dear Sir / Madam, When I am trying to open .exj extension file, I am getting error as mentioned above. Please help me, whether I have to install any java module or something other has to be done. Thanks

Client server program in java [ 1 Answers ]

have a problem about writing client-server program. I want to write two (using TCP and UDP) different client and server programs which are used to transfer an ascii file. Some different information about this project is that the server will wait for client connection and when the client is...


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.