posted 20 years ago
Ok I have a quick question. I am working on an assignment for class and one of the methods I am using is pretty simple. I am using JOptionPane to have a user input a positive value. What I am wondering is if there is a way to distinquish how many digits are in that number that can be known in the next method. I will outline that I am trying to do so that this might make sense:
First I will write a method that takes an integer number as input argument and returns the number of digits in that number.
Next I will write a method that takes an integer number and an integer array argument and fills the array with the appropriate digits of the number. So for example it would set intArray[0] to the value 8, intArray[1] to 7, ..., and intArray[4] to 2.
Third I will write a boolean method that takes an integer array argument and returns the value true if the array is a palindrome else returns false.
Last I will write the main method that prompts the user repeatedly for an integer number, that uses the first method to find out the number of digits in that number, allocates the int array for that size, calls the second method to populate the array with the digits of the number, calls the third method to find out whether the array is a palindrome, and then prints out the result. The program will terminate when the user enters -99.
So ovbiously I do not know how to do all of this yet, but I am working on it. I was just wondering if anyone had any tips about the array and the first method in which I must find out how many digits the value is that the user entered. I think if I understood that I might understand the rest of the assignment a bit more. I feel a little overwhelmed and I promise I did not put all of this on here for someone to do it for me, I just thought it might help for you all to understand where my question was coming from. I appreciate it. Thanks!