Write a program that analyzes text written in the console by counting the number of times...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 A's 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 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, you 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' is 97 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 A's 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 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, you 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' is 97
Expert Answer:
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Microkernel operating systems aim to address perceived modularity and reliability issues in traditional "monolithic" operating systems. (i) Describe the typical architecture of a microkernel...
-
Assignment 5: Hash Table implementation andconcordance There are three parts to this assignment. In the first two parts,you will complete the implementation of a hash map and aconcordance program. In...
-
An excise tax of $1.00 per gallon of gasoline placed on the suppliers of gasoline would shift the supply curve Multiple Choice O down by $1.00. down by more than $1.00. up by $1.00. up by less than...
-
Under no circumstances should a local government be able to condemn property in order to sell it later to real estate developers for private use. Explain
-
Below are four independent scenarios, each of which might suggest issues that could involve ethical misconducts. Each of the situations below will require separate responses. (i) Mark James is the...
-
Why do welfare programs create work disincentives?
-
The three following diagrams show the supply of luxury ocean liners at three different levels of aggregationthe entire world, a particular country, and a particular firm. a. Which diagram shows the...
-
Shankar Company uses a perpetual system to record inventory transactions. The company purchases inventory on account on February 2 for $35,000 and then sells this inventory on account on March 17 for...
-
Tuckered Outfitters plans to market a custom brand of packaged trail mix. The ingredients for the trail mix will include Raisins, Grain, Chocolate Chips, Peanuts, and Almonds costing, respectively,...
-
Blossom Company produces flash drives for computers which have variable costs of $5 per flash drive to produce. Each flash drive sells for $10 each. During the current month, 1240 flash drives were...
-
How does the provision of several types of financial services by one firm lead to a lower cost of information production for the firm?
-
How can conflicts of interest lead to unethical behavior?
-
Conflicts of interest always reduce the flow of reliable information. Is this statement true, false, or uncertain? Explain your answer.
-
Describe two conflicts of interest that occur in universal banks.
-
How can supervisory oversight help reduce conflicts of interest?
-
The following sales and cost data (000s) are for two companies in the transportation industry: Required: 1. Calculate the degree of operating leverage (DOL) for each company. If sales increase from...
-
Discuss the information available from the following techniques in the analysis of inorganic pigments used in antique oil paintings: (i) Powder X-ray diffraction, (ii) Infrared and Raman...
-
Practice Program 5.4 asked you to define a Trivia class that contained strings representing a trivia question and answer to that question. Add an integer for the number of points that the question is...
-
Suppose that we want to compute the geometric mean of a list of positive values. To compute the geometric mean of k values, multiply them all together and then compute the kth root of the value. For...
-
Write a program in a class FlowerCounter that computes the cost of flowers sold at a flower stand. Five kinds of flowerspetunia, pansy, rose, violet, and carnationare stocked and cost, respectively,...
-
What is an overnight reverse repurchase agreement (ON RRP)? What role does the interest on ON RRP play in the way the Fed hits its target for the federal funds rate in the current ample-reserves...
-
A Federal Reserve publication observed that today, the The Feds primary tool for adjusting the federal funds rate is interest on reserve balances. a. Briefly explain the reasoning behind this...
-
In the following graph of the federal funds market, briefly explain whether the banking system is in a scarce reserves regime or an ample-reserves regime. In this situation, briefly explain whether...
Study smarter with the SolutionInn App