Letter Input /* * Main.java * * Created on September 25, 2007, 4:35 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package letterinput; /** * * @author instructor */ public class Main { /** Creates a new instance of Main */ public Main() { } /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here System.out.println("Please enter a letter:"); char aLetter = MyInput.readChar(); //define variable int count = 0; while((aLetter != 'Q') && (aLetter != 'q')) { if((aLetter == 'T')||(aLetter == 't')||(aLetter == 'P')||(aLetter == 'p')) { System.out.println("Invalid Letter.");//you should not count invalid letter } else { count = count + 1; } System.out.println("Please enter the next letter: "); aLetter = MyInput.readChar();
} System.out.println("You entered " + count + " valid letters in total."); } }