I am wondering why the count is not returning anything except 0. I was wondering if it can be done without arrays meaning this way instead. Help is appreciated, thanks!
String word= "";
int value = 0;
while(!word.equalsIgnoreCase("Exit")){
System.out.print("Type words or exit to quit: ");
word = scan.nextLine();
}
value = numberCount(word);
System.out.print("The number of words that start with a number is "+value);
}
public static int numberCount(String str){
int count =0;
char c = str.charAt(0);
if(c >= '0' && c <= '9'){
count++;
}
return count;
}
}