dimanche 19 avril 2015

Palindrome won't output correcly


import java.util.*;

public class Palindrome{


public static void main( String[] args ){
String word=getWord();
boolean w=isPalindrome(word);
if(w==true)
System.out.println(word + " is a palindrome");
else
System.out.println(word + " is not a palindrome");
}


public static String getWord(){
Scanner keyboard = new Scanner( System.in );
String word;
System.out.print("Enter a word: ");
word=keyboard.nextLine();
return word;
}
public static boolean isPalindrome(String word){
int y=word.length();
for (int i = 0; i < y; i++) {
if (word.charAt(i) != word.charAt(y-i)
return false;
}
return true;
}
}



When I compile the program is comes up with error: ')' expected on line 33, but I don't know why



I'm trying to create a program that allows the user to input a word and then output whether or not the word is a palindrome




Aucun commentaire:

Enregistrer un commentaire