Computer Applications
Write a program in Java to accept a number and make it a palindrome number by concatenating the number with its reverse.
Sample Input:
427
Sample Output:
427724
Answer
import java.util.Scanner;
public class KboatPalindrome
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter Number: ");
int num = in.nextInt();
int temp = num;
int count = 0;
int newNum = 0;
while (temp != 0) {
int d = temp % 10;
newNum = newNum * 10 + d;
count++;
temp /= 10;
}
newNum = (int)(num * Math.pow(10, count)) + newNum;
System.out.print("Palindrome Number = " + newNum);
}
}