// Helene Martin, CSE 142 // Prompts the user for words and keeps a total of all letters typed import java.util.*; public class WordSum { public static final String SENTINEL = "stop!"; public static void main(String[] args) { Scanner console = new Scanner(System.in); int counter = 0; String word = ""; // First word is out of loop to avoid adding sentinel's length System.out.print("Type a word (or \"" + SENTINEL + "\" to exit): "); word = console.next(); while(!word.equalsIgnoreCase(SENTINEL)) { counter += word.length(); // cumulative sum System.out.print("Type a word (or \"" + SENTINEL + "\" to exit): "); word = console.next(); } System.out.println("You typed " + counter + " characters."); } }