Question: Exercise 3C [25%] Override the paintComponent method. Draw a rectangle for each letter and number. The height of the rectangle should correspond to the frequency

 Exercise 3C [25\%] Override the paintComponent method. Draw a rectangle for
each letter and number. The height of the rectangle should correspond to

Exercise 3C [25\%] Override the paintComponent method. Draw a rectangle for each letter and number. The height of the rectangle should correspond to the frequency of this symbol. If an element has a frequency has 80 elements it does not have to be 80 pixels but can be a multiple e.g. 800 pixels. Each rectangle should be placed next to its neighbour. On top of each rectangle place the symbol whose frequency the rectangle represents followed by a colon, a space and the frequency. E.g. If the 'e' occurred 83 times in the text you should write 'e: 83 over the corresponding bar. See Figure 1 for an example. If you did not complete Exercise 1 use the values from the int array. Figure 1: An example JFrame (1500x1000) displaying the frequencies found in the text. Exercise 3D [5\%] Create another class called MyMain with a main method. In this main method use Text I0 to read the text in input. txt (available on Moodle) into a Textstatistics object. If you did not complete the Exercise 1 and 2 create an int array with 36 elements and assign. each element a random number between 0 and 99. Create a JFrame with size 15001000 pixels and add a TextstatisticsDisplay object to it. Provide the TextStatistics object or the int array you just read to the TextStatisticsDisptay constructor. Make the JFrame visible. You will have to surround the code with an appropriate try/catch block. Create a class called TextStatisticsDisplay. Extend this class from JComponent. Add a private variable of type TextStatistics. If you have not completed Exercise 1 replace TextStatistics with an int array with 36 elements in all Exercises. Exercise 3B [5\%] Add a constructor to the class that receives a TextStatistics parameter. Initialise the variable you created in 3A with this parameter. If you have not completed Exercise 1 initialise the int array with an int array parameter

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!