/** * Write a description of class TestCharData here. * * @author (your name) * @version (a version number or a date) */ import java.util.*; public class TestCharData { public static void main(String [] args) { Scanner keyboard = new Scanner(System.in); System.out.print("Type in a string: "); String input = keyboard.nextLine(); // examine the String and see what is in it int letters = 0; int digits = 0; int whiteSpace = 0; for (int i = 0; i < input.length(); i++) { char ch = input.charAt(i); if (Character.isLetter(ch)) letters++; else if (Character.isDigit(ch)) digits++; else if (Character.isWhitespace(ch)) whiteSpace++; } System.out.println("letter count = " + letters); System.out.println("digit count = " + digits); System.out.println("white space count = " + whiteSpace); } }