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 00:30
Jenny wants to look at row 345 and compare it to row 17. what can she do if she wanted to easily adjust to see both at once?
Answers: 3
question
Computers and Technology, 22.06.2019 13:00
Why the bear has a slunky tail determine the meaning of the word slunk in the story
Answers: 1
question
Computers and Technology, 23.06.2019 16:30
You have read about the beginnings of the internet and how it was created. what was the internet originally created to do? (select all that apply) share research. play games. communicate. share documents. sell toys
Answers: 1
question
Computers and Technology, 24.06.2019 11:20
Print "censored" if userinput contains the word "darn", else print userinput. end with newline. ex: if userinput is "that darn cat.", then output is: censoredex: if userinput is "dang, that was scary! ", then output is: dang, that was scary! note: if the submitted code has an out-of-range access, the system will stop running the code after a few seconds, and report "program end never reached." the system doesn't print the test case that caused the reported message.#include #include using namespace std; int main() {string userinput; getline(cin, userinput); int ispresent = userinput.find("darn"); if (ispresent > 0){cout < < "censored" < < endl; /* your solution goes here */return 0; }
Answers: 3
You know the right answer?
Implement a Java program using simple console input & output and logical control structures such...
Questions
Questions on the website: 13722363