public class MyClass {
private static boolean OnlyOneZero(String str) {
int count = 0;
for (char ch : str.toCharArray()) {
if (ch == '0') {
count++;
}
}
return count == 1;
}
public static void main(String args[]) {
final String s1 = "294098";
System.out.println(OnlyOneZero(s1) ? "yes" : "no");
final String s2 = "47034099";
System.out.println(OnlyOneZero(s2) ? "yes" : "no");
}
}
/*
run:
yes
no
*/