Yeah I know the usual Palindrome problem, but anyway here it is.
Given a number greater than zero and up to 200.
Find Palindrome of it by adding its reverse to it and repeating until a Palindrome is reached.
If taken more than 10 iterations stop.

So here is my code. I think my main problem is in how I take in the inputed number.
It needs to be called like this: %java Palindrome 78
I used this method before for strings but apparently it doesnt work for ints, so I am lost.

The error when compiling is: exception in thread "main" NoSuchMethodError: main

``````public class Palindrome
{
private int num;

public static void main (int[]arg)
{
Palindrome pal = new Palindrome();
pal.num = arg[0];
int limit = 10;
int count = 0;

//Case where initial number is negative or greater than 200
if ((pal.num <= 0) || (pal.num > 200))
System.out.println("Number not applicable, must be greater than 0 and up to 200.");

else
{
int newNum = pal.num;
while (isPalindrome(newNum) == false)
{
if (count > limit)
{
System.out.println("The number " + pal.num + " takes more than 10 steps to reach a palindrome.");
}

else
{
System.out.println(newNum);
newNum = newNum + reverseNumber(newNum);
count = count + 1;
}

}
System.out.println(newNum);
}

}

public static int reverseNumber(int number)
{
int reversedNumber = 0;
while (number > 0)
{
reversedNumber = number * 10 + number %10;
number = number / 10;
}
return reversedNumber;
}

public static boolean isPalindrome(int number)
{
if (number == reverseNumber(number))
return true;
else
return false;
}

}``````

Thanks for the help.

Please try this code. Compile the program in the command prompt using javac Palindrome.java and run the program by giving java Palindrome 121 in the command prompt. Hope this will work fine for you. If there is any change kindly let me know.

``````public class Palindrome
{
private int num;

public static void main (String []arg)
{
Palindrome pal = new Palindrome();
pal.num = Integer.parseInt(arg[0]);
int limit = 10;
int count = 0;

//Case where initial number is negative or greater than 200
if ((pal.num <= 0) || (pal.num > 200))
System.out.println("Number not applicable, must be greater

than 0 and up to 200.");

else
{
int newNum = pal.num;
while (isPalindrome(newNum) == false)
{
if (count > limit)
{
System.out.println("The number " + pal.num + "

takes more than 10 steps to reach a palindrome.");
break;
}

else
{
System.out.println(newNum);
newNum = newNum + reverseNumber(newNum);
count = count + 1;
}

}
System.out.println(newNum);
}

}

public static int reverseNumber(int number)
{
int reversedNumber = 0;
while (number > 0)
{
reversedNumber = number * 10 + number %10;
number = number / 10;
}
return reversedNumber;
}

public static boolean isPalindrome(int number)
{
if (number == reverseNumber(number))
return true;
else
return false;
}

}``````

Awesome, thank you very much