Starting from:
$30

$24

Laboratory Exercise 3 Solution

A printout showing the problem, solution method, codes developed, and outputs produced for the tests indicated is due during and before the end of the class on Monday, 19 November 2018. The deadline is strictly observed.







Implement a Java class PieChart that displays a pie chart of the probabilities of the n most frequent occurrences of an event to be specified in part 3 of the exercise. The probability of event is given by the equation:



In the pie chart:




The area of each segment is proportional to the probability of the corresponding event:



2




Each segment has a different color;
Each segment has a legend showing the event and its probability;
The segments are displayed in order decreasing probability;



The last segment represents “All Other Events” and their cumulative probability. For example, in the graph below where the event is the occurrence of a letter in a text: n = 3, and the probability of All Other Events is one minus the sum of the probabilities of events e, s, and i;










































The PieChart class includes appropriate constructors and a method draw that draws the pie chart. The drawing pane should include appropriate GUI components to input the number of events, n, and display the pie chart together



with the events probabilities. You may amend and use the class hierarchy in previous exercises, but in any case you may only use JavaFX graphics and your own classes and methods for the operations included.




Implement a Java class HistogramLetters that calculates the n most frequent letters in “Emma” by Jane Austen (file Emma.txt) and their probabilities. The HistogramLetters class utilizes the drawing pane above to draw a pie chart of the letter probabilities.


More products