// Helene Martin, CSE 142 // Prompts the user for words until they type quit. Reports the // total number of characters typed and the longest word typed. import java.util.*; public class WordSum2 { public static final String SENTINEL = "quit"; public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("Type in a word or \"" + SENTINEL + "\" to quit: "); String word = console.next(); int letters = 0; int max = 0; // shortest possible String -- anything typed will be longer while (!word.equals(SENTINEL)) { letters += word.length(); if (word.length() > max) { max = word.length(); } System.out.print("Type in a word or \"" + SENTINEL + "\" to quit: "); word = console.next(); } System.out.println(letters); System.out.println(max); } }