Question
Exercise 1 [Total 20%] Exercise 1A [5%] Create a class called TextStatistics. Add two private variables to the class. An int array with 26 elements
Exercise 1 [Total 20%] Exercise 1A [5%] Create a class called TextStatistics. Add two private variables to the class. An int array with 26 elements to store the frequencies of letters in a text and an int array with 10 elements to store the frequencies of numbers in a text. Both variables should be declared and initialised to arrays with default values. The class should not have a non-default constructor. In this exercise we will not consider any other symbols besides letters and numbers. Exercise 1B [5%] Add four public methods: A method that returns void called incrementLetterFrequency that has an int as parameter. This method should increment the frequency of the letter whose index in the array is given by the parameter. A method that returns void called incrementNumberFrequency that has an int as parameter. This method should increment the frequency of the letter whose index in the array is given by the parameter. A method that returns int called getLetterFrequency that has an int as parameter. This method should return the frequency of the letter whose index in the array is given by the parameter. A method that returns int called getNumberFrequency that has an int as parameter. This method should return the frequency of the letter whose index in the array is given by the parameter. Exercise 1C [10%] Override the toString() method. The returned String should have this format with the values following the : corresponding to the frequencies of the corresponding alphanumeric symbols (letter and number frequencies should be printed in two separate lines (there are more lines in the example due to the limited page width)): a: 43, b: 5, c: 25, d: 20, e: 83, f: 10, g: 8, h: 16, i: 39, j: 1, k: 10, l: 19, m: 17, n: 29, o: 51, p: 15, q: 1, r: 50, s: 46, t: 43, u: 23, v: 2, w: 9, x: 6, y: 11, z: 1 0: 1, 1: 4, 2: 6, 3: 0, 4: 1, 5: 2, 6: 1, 7: 0, 8: 0, 9: 0
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