Starting from:

$40

CSc 22100: Software Design Laboratory Exercise 3 Solved

 

CSc 22100: Software Design Laboratory
Exercise 3

 

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.  The deadline is strictly observed.

 

A demonstration of your application is required.
 

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

 

𝐹𝑟𝑒𝑞𝑢𝑒𝑛𝑐𝑦𝑜𝑓𝑒𝑣𝑒𝑛𝑡

𝑃𝑟𝑜𝑏𝑎𝑏𝑖𝑙𝑖𝑡𝑦𝑜𝑓𝑒𝑣𝑒𝑛𝑡 =   

∑ 𝐹𝑟𝑒𝑞𝑢𝑒𝑛𝑐𝑖𝑒𝑠𝑜𝑓𝑎𝑙𝑙𝑒𝑣𝑒𝑛𝑡𝑠

 

In the pie chart:

 

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

 

𝐶𝑒𝑛𝑡𝑟𝑎𝑙𝑎𝑛𝑔𝑙𝑒𝑜𝑓𝑠𝑒𝑔𝑚𝑒𝑛𝑡

𝑃𝑟𝑜𝑏𝑎𝑏𝑖𝑙𝑖𝑡𝑦𝑜𝑓𝑒𝑣𝑒𝑛𝑡 =   

2𝜋

 

ii.         Each segment has a different color;

iii.       Each segment has a legend showing the corresponding event and its

probability;

iv.        The segments are displayed in order of decreasing or increasing probability;

v.         The last segment represents “All Other Events” and their cumulative probability.  As an 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 eventse, s, and i;

  

 

 

 

2.         The MyPieChart class includes appropriate constructors and a method draw that draws the pie chart. The drawing canvas should include appropriate GUI components to input the number of events, n, and display the pie chart together with the events and their corresponding probabilities.

 

3.         The MyPieChart class may inherit or otherwise utilize the MyShape 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.

 

4.         Implement a Java class HistogramAlphaBet that calculates the n most frequent alphabet characters in “Alice's Adventures in Wonderland” by Lewis Carroll (file Alice in Wonderland.txt) and their probabilities.  The HistogramAlphaBet class utilizes a map collection for statistical calculations and the drawing canvas above to draw a pie chart of the probabilities.

 

More products