Page 1 of 1

Please use Java: A Palindrome is a word (or a number) that reads the same backwards. In this assignment you will be writ

Posted: Sun Jul 10, 2022 11:23 am
by answerhappygod
Please use Java:
A Palindrome is a word (or a number) that reads the samebackwards. In this assignmentyou will be writing a program that repeatedly prompts a user for apositive integer numberand tests whether the number is a palindrome. Your program shouldconvert the integervalue given by the user into an int array storing each digit of thenumber in the appropriateelement of the array. It should then check to see whether the arrayis a palindrome. Yourprogram should follow the guidelines given below.1. Write a method called getSize( int num ) that takes an integernumber as inputargument and returns the number of digits in that number. For e.g.,getSize( 234 ) shouldreturn 3 and getSize( 76 ) should return 2.2. Write a method called fillArray( int num, int[] intArray ) thattakes an integernumber and an integer array argument and fills the array with theappropriate digits of thenumber. For e.g., calling the above method fillArray( 87432,intArray ) wouldset intArray[0] to the value 8, intArray[1] to 7, ..., andintArray[4] to 2.3. Write a boolean method called isPalindrome( int[] intArray )that takes an integerarray argument and returns the value true if the array is apalindrome else returns false.4. Finally, write the main method that prompts the user repeatedlyfor an integer number,uses the getSize method to find out the number of digits in thatnumber, allocatesthe intArray for that size, calls the method fillArray to populatethe array with the digitsof the number, calls the isPalindrome method to find out whetherthe array is apalindrome, and prints out the result. Your program shouldterminate when the user enters-99.Notes:In Java you can allocate an array using a variable for the size,i.e., int[] intArray = newint[size]; where size is an int variable.You should use Command Line Interface or Console for allinput/output.