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
Java
Java Iterative Stmts
1 Like
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);
}
}Output

Answered By
1 Like
Related Questions
Write a program in Java to find the Fibonacci series within a range entered by the user.
Sample Input:
Enter the minimum value: 10
Enter the maximum value: 20Sample Output:
13Define a class to accept a number from user and check if it is an EvenPal number or not.
(The number is said to be EvenPal number when number is palindrome number (a number is palindrome if it is equal to its reverse) and sum of its digits is an even number.)
Example: 121 – is a palindrome number
Sum of the digits – 1+2+1 = 4 which is an even numberTo execute a loop 10 times, which of the following is correct?
- for (int i=11;i<=30;i+=2)
- for (int i=11;i<=30;i+=3)
- for (int i=11;i<20;i++)
- for (int i=11;i<=21;i++)