0

:rolleyes: Hello All,
I am very new to writing Java program so am here looking for help but most I want learn more about java. I am try to understand the code but it does not click for me.
My question is: I am trying to write a program to create an array size of 25 and fill it with 5 digit palindromes. I also need to print out how many of the 25 are even and how many are odd.
Now, I know how to make the array of 25 and I set it up so that the palindromes are ramdonly pick but I have to compare the digit to make sure that they are palindromes. How should I do that! How do I compare cell of the Array or should I convert the number into strings!

This is what I have so far:

//class palindromesarray
 
class palindromesarray
{
              public static void main(String args[])
                {
                   int number[];
                   number = new int[25];
                   for(int i = 0; i < 25; i++) number[i] = (int)Math.floor(Math.random()*100000+1);
                  for(int i=0; i<25; i++)
                  System.out.println(number[i]);
                }
}
2
Contributors
1
Reply
3
Views
11 Years
Discussion Span
Last Post by iamthwee
0

How should I do that! How do I compare cell of the Array or should I convert the number into strings!

Do whatever you're allowed. If you can cannot convert to a string then use the modulus operator to separate the digits.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.