Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please write a code in java Write a program CountLetters that will read a line of text that ends with a period, which serves as
Please write a code in java
Write a program CountLetters 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 so that the element at index contains the number of
s the element at index contains the number of 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 Characters and Strings Manipulation Chapter. 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
for that character. For example, the argument results in as the return value, the argument
gives as the return value, and so on Note that you can use a type cast, such as intletter to
change a char to an int. Of course, this will not get the number you want, but if you subtract
inta you will then get the right index. Allow the user to repeat this task until the user says she
or he is through.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started