Pages

1/19/2014

UVA 10945 Mother Bear Solution

import java.util.Scanner;

class Main {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
boolean flag = true;
String s= null;
while (flag) {
s =sc.nextLine().toLowerCase().replaceAll("[^a-z]", "");
if (s.equalsIgnoreCase("DONE")) break;
StringBuffer sb = new StringBuffer(s);
if(s.equalsIgnoreCase(sb.reverse().toString())) System.out.println("You won't be eaten!");
//if (s(sb.reverse()))
else System.out.println("Uh oh..");
}
}

}

No comments :

Post a Comment