Scanner/Calling Method Program
Ok, this program compiles, but doesn't really work, I think it is because when the method "input" is called Scanner sn isn't passing the input to String str, any help would be great!
import java.util.Scanner;
import java.lang.*;
class pp
{
publicstaticvoid main(String[] args)
{
Scanner sn =new Scanner(System.in);
int test;
int length;
String str =new String();
instructions();
input(sn, str);
length = str.length();
System.out.println(str +"564" + length);
compute(length, str);
}
staticvoid instructions()
{
System.out.println("Welcome to Palindrome Prover!");
System.out.println("We will now determine if you have a palindrome.");
}
staticvoid input(Scanner sn, String str)
{
System.out.println("Please enter your input now...");
str = sn.next();
System.out.println("Thank You, please hold.");
}
staticvoid compute(int length, String str)
{
char[] tempCharArray =newchar[length];
char[] charArray =newchar[length];
// put original string in an array of chars
for (int y = 0; y < length; y++)
{
tempCharArray[y] = str.charAt(y);
}
// reverse array of chars
for (int x = 0; x < length; x++)
{
charArray[x] = tempCharArray[length - 1 - x];
}
String reversePalindrome =new String(charArray);
System.out.println(reversePalindrome);
}
}

