// Check the "i before e, except after c" spelling rule // // Examples: // field, chief, pie, ceiling, receive // ?? either, lei, weigh // Solution as developed in class // Note: This code assumes the word is lower case // See handout for solution import java.util.*; public class IbeforeE { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("Type a word: "); String word = console.next(); System.out.print(word + " is spelled "); if (!ieOkay(word)) { System.out.println("incorrectly"); } else { System.out.println("correctly"); } } // Look for an error // ei without a c right before it // Walk through the string looking for ei public static boolean ieOkay(String s) { for (int i=0; i