Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use eclipse java 2. Problem b (PA8b.java) Write a program that analyzes text written in the console by counting the number of times each

image text in transcribed Please use eclipse java
2. Problem b (PA8b.java) Write a program that analyzes text written in the console by counting the number of times each of the 26 letters in the alphabet occurs. Uppercase and lowercase letters should be counted together (for example, both 'A' and 'a' should count as an A). Any characters that are not letters should be ignored. You must prompt the user to enter the text to be analyzed. Then, for any letter that appeared at least once in the text, print out the number of times it appeared (and do so in alphabetical order). An effective way to count characters is to read from the console string-by-string, and loop through all of the characters of each of these strings. Similar to Problem a, the hasNext() method of the scanner will be useful, and when testing in Eclipse, press enter and then, once on the empty line, press CTRL-D when you are done typing the text. You must use an array to keep track of how many times each letter is seen in the text. The array should have 26 elements (one for each letter in the alphabet). Index o should be used to track the number of As in the file, index 1 to track the B's, index 2 to track the C's, etc., up to index 25 for the Z's. You could use a 2 massive if/else block, but the whole reason to use arrays is to make your programs easier. So, instead think about how to convert each character you read into the correct index and then increment that value in the array. For example, if you read an A, then you should increment the value in index o. Specifically, ou will need to determine if the character is an uppercase letter (between 'A' and Z"), a lowercase letter (between 'a' and z), or something else. If it is a letter, convert it into the appropriate index. Recall that characters and integers are interchangeable via the ASCII table conversion, Consider this example to help get you started: char input "z"; int index - input - 'a"; // index equals 25, as z' is 122 and 'a. s 97 You have been supplied JUnit tests for several example input texts, including an empty text, one with no letters, upper/lower/mixed case letters, and Hello World

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

Creating A Database In Filemaker Pro Visual QuickProject Guide

Authors: Steven A. Schwartz

1st Edition

0321321219, 978-0321321213

More Books

Students also viewed these Databases questions

Question

Different formulas for mathematical core areas.

Answered: 1 week ago

Question

Select suitable tools to analyze service problems.

Answered: 1 week ago