Write a program that will analyze a string by counting the number of each alphabetic letter in the string and then printing a vertical histogram showing the frequency of the letters in the string. For example, if text = "I love problem-solving.", your program should plot when the histogram is printed:  * *  * * * * *  * * * * * * * * * * * * --------------------------------------------------- a b c d e f g h i j k l m n o p q r s t u v w x y z Note that all special characters including blanks are ignored and alphabet letters are caseinsensitive. Create your source code file named Lab10FirstnameLastname.java in NetBeans and add the following menu to the main method in the Lab10FirstnameLastname class. T: Enter a text string P: Plot alphabetic frequencies in the string Q: Quit Select an option: Add the following Histogram class to your source code file and complete the setText(String t) and drawHistogram() methods to do the work for options T and P in your main menu. The setText(String t)method changes the string stored in text to equal t. The drawHistogram() method counts each alphabetic letter occurrence, a to z, in the string text and then stores the count of each letter in an int array of size 26 since there are 26 letters in the alphabet. For example, the number of a’s in text would be stored in the 0 index position of your int array. As stated before, the counts are case-insensitive meaning both uppercase I and lowercase i count as an occurrence of the letter i. Last, use the contents in the int array, to output the vertical histogram to the user using nested For loops and printf(). class Histogram{  //class variables (aka data members)  String text;  //constructor  Histogram(){ text = "I love problem-solving!";  }  //additional class methods you are to complete  //this method changes the string stored in text to the value  //passed by the caller through parameter t  void setText(String t){ //your goes code here  }  //This method creates an array to hold the letter frequencies  //and outputs the vertical histogram based on the array contents  //Use nested For loops and printf() to output the histogram  void drawHistogram(){ //your goes code here  } }  1. You must use printf() and nested For loops to output the histogram in this lab. 2. You must use an int array to store the counts of occurrences of each letter. 3. The only built-in String methods you can use are lowercase(), length() and charAt(). 4. If appropriate for this algorithm, you should validate any input from the user to make sure the data input is an appropriate value to work in your program’s logic. You don’t have to worry about validating that it is the correct data type. For now, assume the user is only giving you the correct data type and just worry about validating the value given is usable in your program

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write a program that will analyze a string by counting the number of each alphabetic letter in the string
and then printing a vertical histogram showing the frequency of the letters in the string.
For example, if text = "I love problem-solving.", your program should plot when the
histogram is printed:
 * *
 * * * * *
 * * * * * * * * * * * *
---------------------------------------------------
a b c d e f g h i j k l m n o p q r s t u v w x y z
Note that all special characters including blanks are ignored and alphabet letters are caseinsensitive.
Create your source code file named Lab10FirstnameLastname.java in NetBeans and add the
following menu to the main method in the Lab10FirstnameLastname class.
T: Enter a text string
P: Plot alphabetic frequencies in the string
Q: Quit
Select an option:
Add the following Histogram class to your source code file and complete the setText(String
t) and drawHistogram() methods to do the work for options T and P in your main menu.
The setText(String t)method changes the string stored in text to equal t.
The drawHistogram() method counts each alphabetic letter occurrence, a to z, in the string
text and then stores the count of each letter in an int array of size 26 since there are 26 letters in the alphabet. For example, the number of a’s in text would be stored in the 0 index
position of your int array. As stated before, the counts are case-insensitive meaning both
uppercase I and lowercase i count as an occurrence of the letter i. Last, use the contents in the
int array, to output the vertical histogram to the user using nested For loops and printf().
class Histogram{
 //class variables (aka data members)
 String text;
 //constructor
 Histogram(){
text = "I love problem-solving!";
 }
 //additional class methods you are to complete
 //this method changes the string stored in text to the value
 //passed by the caller through parameter t
 void setText(String t){
//your goes code here
 }
 //This method creates an array to hold the letter frequencies
 //and outputs the vertical histogram based on the array contents
 //Use nested For loops and printf() to output the histogram
 void drawHistogram(){
//your goes code here
 }

1. You must use printf() and nested For loops to output the histogram in this lab.
2. You must use an int array to store the counts of occurrences of each letter.
3. The only built-in String methods you can use are lowercase(), length() and charAt().
4. If appropriate for this algorithm, you should validate any input from the user to make
sure the data input is an appropriate value to work in your program’s logic. You don’t
have to worry about validating that it is the correct data type. For now, assume the user
is only giving you the correct data type and just worry about validating the value given is
usable in your program

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education