In: Computer Science
Program 5: The concept of a 5-digit palindrome number is a 5-digit number that reads the same from left to right and from right to left. For example, 12121, 45454, and 14741 are valid 5-digit palindrome numbers. Design (pseudocode) and implement (source code) a program (name it FiveDigitPalindrom) that reads a 5-digit number from the user (as integer value, not string) and then mathematically (using division and remainder operations) determines whether the entered number is a 5-digit palindrome or not. Assume valid inputs are from 11111 to 9999. The program rejects any input outside that range with the message “Invalid 5-digit number. Try again”. Document your code and properly label the input prompts and the outputs as shown below.
Please HELP!!! Am I missing something...
import java.util.Scanner;
public class fiveDigitpalindrome {
public static void main(String[] args) {
int number = 0;
Scanner input = new Scanner
(System.in);
System.out.print("Enter a 5-digit
number: ");
number = input.nextInt();
if (number < 9999 &&
number > 10000) {
int fiveDigits =
0, reverse = 0;
int temp =
number;
while (temp >
0) {
fiveDigits = temp % 10;
reverse = (reverse * 10) + fiveDigits;
temp = temp/10;
} // end while
loop
if (number ==
reverse) {
System.out.println("Judgement: Valid 5-digit palindrome.");
} else
System.out.println("Judgement: Invalid 5-digit palindrome.");
}
else
System.out.println("Judgement: Invalid 5-digit number. Try
Again!");
}
}
import java.util.Scanner; public class FiveDigitPalindrome { public static void main(String[] args) { int number = 0; Scanner input = new Scanner (System.in); System.out.print("Enter a 5-digit number: "); number = input.nextInt(); if (number < 99999 && number > 10000) { int fiveDigits = 0, reverse = 0; int temp = number; while (temp > 0) { fiveDigits = temp % 10; reverse = (reverse * 10) + fiveDigits; temp = temp/10; } // end while loop if (number == reverse) { System.out.println("Judgement: Valid 5-digit palindrome."); } else System.out.println("Judgement: Invalid 5-digit palindrome."); } else System.out.println("Judgement: Invalid 5-digit number. Try Again!"); } }