subject

Implement a Java program using simple console input & output and logical control structures such that the program prompts the user to enter a 5 digit integer as input and does the following tasksThe program checks whether the input number is a palindrome or not and prints the result of this palindrome check. A number is a palindrome if it reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611; whereas 12312, 55565, 45545 and 11621 are not a palindrome. Your program should print "The number is palindrome" or "The number is not palindrome" after checking the input number. The program checks whether the input number has 5 digits or not and prints the error message "Invalid number" if the input number is not a 5 digit one. I posted my code below, I think I have a good start with reversing the number but I'm not sure how to implement the portion of how to actually check if it is a palindrome. import java. util. Scanner;public class Problem2 { public static void main(String[] args) { int number;Scanner scanner = new Scanner(System. in);System. out. println("Enter a positive integer between 1 and 5 digits long that you would like to test for a palindrome: ");num = in. nextInt();for( ;num != 0; ){reversenum = reversenum * 10;reversenum = reversenum + num%10;num = num/10;} } }

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 03:00
Data is processed, stored, and transmitted as a series of 1s and 0s. each 1 or 0 is called a(n) . a series of eight 0s and 1s, called a(n) , represents one character—a letter, number, or punctuation mark. data becomes when it is presented in a format that people can understand and use. digital signals are represented by two different , such as +5 volts and +.2 volts. digital data can also take the form of light and dark spots etched onto the surface of a cd or the positive and negative orientation of particles on the surface of a hard disk. data consists of numbers that might be used in arithmetic operations. it can be represented digitally using the number system. data is composed of letters, symbols, and numerals that are not used in arithmetic operations. computers represent this type of data using , ebcdic, unicode, or utf-8. data is quantified using terms such as or kibibyte (1024 bytes), and prefixes such as or mebi (1,048,576), and giga or (1,073,741,824). to reduce file size and transmission times, digital data can be compressed. compression provides the means to compress data and reconstitute it into its original state. compression throws away some of the original data during the compression process. compressed files usually have at the end of the file name and are represented with special icons. these files have to be or unzipped before you can view the data they contain.
Answers: 1
question
Computers and Technology, 22.06.2019 16:00
If a client wants to make minor edits, what should he/she use?
Answers: 3
question
Computers and Technology, 22.06.2019 18:30
Which of the following commands is more recommended while creating a bot?
Answers: 1
question
Computers and Technology, 24.06.2019 02:30
Which option completes the explanation for conflict of interest in an organization
Answers: 1
You know the right answer?
Implement a Java program using simple console input & output and logical control structures such...
Questions
question
History, 24.05.2021 17:30
question
Mathematics, 24.05.2021 17:30
question
Mathematics, 24.05.2021 17:30
question
Mathematics, 24.05.2021 17:40
question
Mathematics, 24.05.2021 17:40
question
Mathematics, 24.05.2021 17:40
question
Mathematics, 24.05.2021 17:40
question
Mathematics, 24.05.2021 17:40
Questions on the website: 13722363