/* Jessica Miller, CSE 142 This program is a variation on the Sentinel program. It uses a do/while loop instead of a while loop. The fencepost problem still must be addressed with a do/while loop. */ import java.util.*; // for Scanner public class Sentinel2 { public static final String SENTINEL = "quit"; public static void main(String[] args) { Scanner console = new Scanner(System.in); // all variable(s) in your while loop test // MUST be declared before/outside the while loop // fencepost problem: pull first post out int count = 0; String word = ""; // post do { count += word.length(); // wire System.out.print("Type a word (or \"" + SENTINEL + "\" to exit): "); word = console.next(); } while (!word.equals(SENTINEL)); System.out.println("You typed " + count + " characters."); } }