Thursday, February 22, 2024
EducationJava GUI Program to Find if a number is Palindrome or not

# Java GUI Program to Find if a number is Palindrome or not

A palindrome number is a number that remains the same when its digits are reversed. For example, the number 121 is a palindrome because it reads the same forwards and backwards. Similarly, the number 1221 is also a palindrome, as well as the number 12321.

Palindrome numbers have been studied in mathematics for centuries, and have been found to have several interesting properties. For example, palindrome numbers are often symmetric, which means that their digits are arranged in a way that creates a mirror image. This symmetry can make them easy to recognize and remember.

Palindrome numbers are also used in several practical applications, such as in coding theory and cryptography. In coding theory, palindrome numbers are used to detect errors in transmission and storage of data. In cryptography, palindrome numbers can be used to create secret codes and messages that are difficult to crack.

Palindrome numbers can be found in different numeral systems, including decimal, binary, and even Roman numerals. In addition, palindrome numbers can also be found in words and phrases, such as “madam” and “level”.

Palindrome numbers are not limited to positive integers. Negative numbers can also be palindrome numbers, for example -121 is a palindrome number.

In conclusion, palindrome numbers are a fascinating and versatile aspect of mathematics. They have interesting properties, practical applications, and can be found in different numeral systems. They continue to be an area of ongoing research and study in mathematics.

A simple Java program to check if a number is palindrome or not is:

```int num = Integer.parseInt(textField1.getText()); //replace textField1with actual one
int n = num; //used to store the value to check at the end of loop
int reverse=0, remainder;
while(num > 0)
{
remainder = num % 10;
reverse = reverse * 10 + remainder;
num = num / 10; }
if(reverse == n)
System.out.println(n+” is a Palindrome Number”);
else
System.out.println(n+” is not a Palindrome Number”);
```

## CLI Program to Find if a number is palindrome or not

```import java.util.Scanner;
public class PalindromeChecker {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number: ");
int num = sc.nextInt();
int temp = num;
int reversed = 0;
while (temp != 0) {
int digit = temp % 10;
reversed = reversed * 10 + digit;
temp /= 10;
}
if (num == reversed) {
System.out.println(num + " is a palindrome");
} else {
System.out.println(num + " is not a palindrome");
}
sc.close();
}
}

```

## Write a Program in C language to Find if a number is palindrome or not

```#include
#include

int main() {
int num, reversedNum = 0, rem, originalNum;
printf("Enter a number: ");
scanf("%d", &num);
originalNum = num;

while(num != 0) {
rem = num % 10;
reversedNum = reversedNum * 10 + rem;
num /= 10;
}

if(originalNum == reversedNum) {
printf("%d is a palindrome number", originalNum);
} else {
printf("%d is not a palindrome number", originalNum);
}

return 0;
}
```

## Write a Program in C++ language to Find if a number is palindrome or not

```#include
using namespace std;

bool isPalindrome(int num) {
int originalNum = num;
int reversedNum = 0;
while (num > 0) {
reversedNum = reversedNum * 10 + num % 10;
num /= 10;
}
if (originalNum == reversedNum) {
return true;
} else {
return false;
}
}

int main() {
int num;
cout ​`oaicite:{"index":0,"invalid_reason":"Malformed citation << \"Enter a number: \";\n cin >>"}`​ num;

if (isPalindrome(num)) {
cout << num << " is a palindrome." << endl;
} else {
cout << num << " is not a palindrome." << endl;
}

return 0;
}
```

Isrg Team
Isrg Team is a member of Digital Pradesh News Networks, a collective of journalists, reporters, writers, editors, lawyers, advocates, professors, and scholars affiliated with the Digital Pradesh News Network.