Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java program PLEASE NO COPYING, this is different from previous questions!! ******The input should be able to be on multiple lines until the user adds

Java program PLEASE NO COPYING, this is different from previous questions!!

******The input should be able to be on multiple lines until the user adds a period. LOOK AT SAMPLE OUTPUT FOR DETAILS PLEASE!!!!!!!!!!!

Write a program that will read in a line of text and output a list of all the letters that occur in the text, along with the number of times each letter occurs. End the line with a period that serves as a sentinel value. The letters should be listed in alphabetical order when they are output. Use an array of base type int of length 26, so that each indexed variable contains the count of how many letters there are. Array indexed variable 0 contains the number of as, array indexed variable 1 contains the number of bs 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: You will want to use one of the methods toUpperCase or toLowerCase in the wrapper class Character as described in Chapter 5. 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, such as a returning 0, b returning 1, and so forth. Note that you can use a type cast to change a char to an int, like (int)letter. This will not get the number you want, but if you subtract (int)'a', you will then have the right index. Allow the user to repeat this task until the user says she or he is through.

SAMPLE OUTPUT:

Please enter the text ending with a period:

A parameter of return type

of a method can be an entire

multidimensional array.

Letter: a freq. 9

Letter: b freq. 1

Letter: c freq. 1

Letter: d freq. 2

Letter: e freq. 9

Letter: f freq. 2

Letter: h freq. 1

Letter: i freq. 4

Letter: l freq. 2

Letter: m freq. 4

Letter: n freq. 6

Letter: o freq. 4

Letter: p freq. 2

Letter: r freq. 7

Letter: s freq. 1

Letter: t freq. 6

Letter: u freq. 2

Letter: y freq. 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions

Question

Discuss the goals of financial management.

Answered: 1 week ago

Question

6. Explain the power of labels.

Answered: 1 week ago

Question

5. Give examples of variations in contextual rules.

Answered: 1 week ago

Question

f. What stereotypes were reinforced in the commercials?

Answered: 1 week ago