Write a program that will read a line of text that ends with a period, which serves as a sentinel value. Display all the letters that occur in the text, one per line and in alphabetical order, along with the number of times each letter occurs in the text. Use an array of base type int of length 26, so that the element at index 0 contains the number of a’s, the element at index 1 contains the number of b’s, and so forth. Allow both uppercase and lowercase letters as input, but treat uppercase and lowercase versions of the same letter as being equal. Hints: Use one of the methods toUpperCase or toLowerCase in the wrapper class Character, described in Chapter 6. You will find it helpful to define a method that takes a character as an argument and returns an int value that is the correct index
This project is a bit challenging to get the loop conditions right. The objective is to keep the array index within bounds and count only letters. Another little problem is how to get the printable character code from the array index after the letter counts have been determined. The "trick" is to know that adding 65 decimal to the array index will produce the ASCII code for the character.
See the code in CountLettersInLine.java.
You might also like to view...
Which of the following requirements is part of the “Protect cardholder data” PCI DSS core principle?
A) Maintain a policy that addresses cybersecurity for all personnel. B) Develop and maintain secure systems and architecture. C) Restrict physical access to cardholder data. D) Protect stored card data.
Where should network management systems generally be placed?
A. out of band B. in the DMZ C. on the perimeter D. in the server farm
The separation of initial values into rows in the declaration statement of a two-dimensional array is not necessary.
Answer the following statement true (T) or false (F)
Preprocessor commands begin with a ____ sign.
a. # b. ! c. // d. */