Question
JAVA **6.3 Using multiple methods ( 10 points ): Palindromes are numbers or words that are same when read from either end. Eg. Avid diva,
JAVA **6.3 Using multiple methods (10 points): Palindromes are numbers or words that are same when read from either end. Eg. Avid diva, civic, 12321, 52925. Write a java program PalindromeByMethods.java that reads in an integer number (any number of digits up to 10 digits) from user input. The program then passes this number on to a method called reportIfPalindrome( ) that returns a boolean value. The method reportIfPalindrome( ) makes a call to another method called reverseNum(int number) that returns the reverse of the original integer back to the reportIfPalindrome( ) method. Based on the original integer and its reversed value received from the reverseNum( ) method, the reportIfPalindrome( ) method decides if the number is a palindrome and passes this information back (a Boolean value) to the main( ) method. Based on the returned value, the main( ) method prints if or not the number is a palindrome. [If you wrote a numOfDigits( ) method for the last program, it will be useful for this program too.]
.
Sample Run 1
This program checks if a user-entered number is a palindrome. Please enter the number: 1234 Printed from main( ): The number entered is: 1234
Making a call to reportIfPalindrome ( ) Now in method reportIfPalindrome ( ) The number received from main( ) is: 1234 Passing the number to reverseNum( ) Result received from reverseNum( )
The reverse of the received number 1234 is 4321. Reporting my decision back to main( ) Back in main( ) The number 1234 is NOT a Palindrome.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started