i am trying to write a program finding palindromes and currently having difficulty achieving the following:
1) input a beginning number
2) add the reverse of that number
3) continue the process until it becomes a palindrome
4) determine the number of iterations necessary for the number to become a palindrome and output the results.
here's what i have so far. thank you in advance
CODE
import java.util.*;
class PROG3
{
public static void main(String[]args)
{
Scanner input = new Scanner(System.in);
Scanner number = input.nextInt(); //error states incompatible types
System.out.println("Please enter a positive number to test");
String number = " "; //error states number already defined in main(java.lang.String[])
String reversed = " ";
int j = 0; //counts the number of iterations
int n = Integer.parseInt(number); //error states cannot find symbol method parseInt(java.util.Scanner)
int r = Integer.parseInt(reversed);
int sum = n+r;
String x = " ";
int x = x.valueOf(sum);
for(int i = number.length-1; i>=0; i--) //error states cannot find variable length
reversed = reversed + number.substring(i,i+1); //error states cannot find symbol method substring(int,int)
j = j+1;