I have to write a program that allows the user to enter a string and the it needs to count the number of upper case letters in the string. This is the code I have come up with, can anyone help me fix it?
import java.util.StringTokenizer;
public class TestStringTokenizer {
/** Main method */
public static void main(String[] args) {
// Create a string and string tokenizer
System.out.println("Enter string");
String s =MyInput.readString();
String upper = s.valueOf("[A-Z]");
StringTokenizer st = new StringTokenizer(upper);
// Retrieve and display tokens
System.out.println("The total number of words is " +
st.countTokens());
while (st.hasMoreTokens())
System.out.println(st.nextToken());
}
}